- 형(타입, type)
- 입력
- 출력
- 형변환
- 문자열
const int INF = 987654321;
또는 const int INF = 1e9;
로 설정 오버플로 방지범위 : –9,223,372,036,854,775,808 ~9,223,372,036,854,775,807
int로 표현 안될 때 쓰기
long long INF = 1e18;
로 쓰면 됨 문제마다 다르므로 이것은 참고만 하기
scanf("%1d", value);
한 자리의 int만 받겠다는 뜻string s; getline(cin, s);
를 이용#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
while(cin >> n){
cout << 1 << '\n';
}
}
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
while(scanf("%d", &n) != EOF){
cout << 1 << '\n';
}
}
cout.precision(7);
cout << num << "\n";
printf("Amenable %d");
printf("%.06lf\n, num);
1.234567int newNum = (int) num;
reverse(words.begin(), words.end());
전체 바꾸기reverse(words.begin(), words.begin() + 3);
앞에 3개 바꾸기words.substr(0, 3);
if(words.find("abc") != string::npos)
와 같이 이용#include <bits/stdc++.h>
using namespace std;
vector<string> split(string input, string delimiter){
vector<string> ret;
long long pos = 0;
string token = "":
while((pos = input.find(delimiter)) != string::npos){ // delimiter가 아직 남았는지 체크
token = input.substr(0, pos); // substr로 분리
ret.push_back(token); // vector에 넣기
input.erase(0, pos + delimiter.length()); // vector에 넣은거까지 삭제
}
ret.push_back(input);
return ret;
}
int main(){
string s = "안녕하세요 띄워쓰기 테스트 해볼게요!";
string d = " ";
vector<string> a = split(s, d);
for(string b : a) cout << b << "\n";
}
이 글은 큰돌님의 '10주완성 C++코딩테스트 | 알고리즘 IT취업'을 수강하고 정리한 내용입니다.