- 좌표 정렬하기 * pair의 정렬조건이 문제의 정렬조건과 같으므로 비교함수를 따로 정의하지 않아도 됌. #include #include #include #include using namespace std; int main() { int n; scanf("%d", &n); vector a(n); for(int i = 0; i < n; i++) { scanf("%d %d", &a[i].first, &a[i].second); } sort(a.begin(), a.end()); for(int i = 0; i < n; i++) { printf("%d %d\n", a[i].first, a[i].second); } return 0; } - 좌표 정렬하기2 * vector에 뒤집어서 저장 #include #inclu..

1) vector의 개념 : (크기 조절이 가능한) 배열 #include #include using namespace std; int main(){ vector myArray(10); //기본값(0)으로 초기화 된 10개의 원소를 가지는 vector myArray를 생성. myArray[0] = 1; myArray[1] = 2; myArray[8] = 4; return 0; } #include #include using namespace std; int main(){ vector myArray(10); //기본값(0)으로 초기화 된 10개의 원소를 가지는 vector myArray를 생성. //배열의 경우 크기를 변경할 수 없지만 vector는 크기 조절이 가능함. for(int i = 0; i < 10..
1. 입력이 몇 개인지 주어지지 않은 경우에는 입력을 EOF까지 받으면 된다. - C : while(scanf("%d %d", &a, &b) == 2), while(scanf("%d %d", &a, &b) != EOF) (scanf의 리턴값은 성공적으로 입력받은 변수의 개수이다.) - C++ : while(cin >> a>> b) 2. 소스 ①C #include int main() { int a,b; while(scanf("%d %d", &a, &b) == 2) { printf("%d\n", a+b); } return 0; } ②C #include int main() { int a,b; while(scanf("%d %d", &a, &b) != EOF) { printf("%d\n", a+b); } retu..