競プロで使うC++の文法

忘備録かねて書いときます

追加もしていく予定

 

・基本

 

#include <iostream>

#include <string>
using namespace std;

int main()
{

    string test = "test";
    cout << "hello" << test << endl;
}

 

・入力

cin >> test;

 

・型

bool: true/false

char: 文字列

int: -2147483648 ~ 2147483647

unsigned int: 0 ~ 4294967295

double:  1.7 x 10の-308乗 ~ 1.7 x 10の308乗

 

・if, else

if () {

}

 

・for, while

for (i = 0; i < 100; i++) {

}

 

while () {

}

 

・配列

int test[100];

 

・ポインタ

int x = 10;

cout << &x;

 

・ハッシュ(連想配列

#include <map>
using namespace std;

 

map<キー型, 値型> オブジェクト名;

 

 

以上