https://www.acmicpc.net/step/1
https://www.acmicpc.net/problem/2557
방법 1
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}
방법 2
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
방법 3
#include <stdio.h>
int main() {
puts("Hello World!");
return 0;
}
https://www.acmicpc.net/problem/10718
방법 1
#include <iostream>
using namespace std;
int main() {
cout << "강한친구 대한육군" << endl;
cout << "강한친구 대한육군" << endl;
return 0;
}
방법 2
#include <iostream>
int main() {
std::cout << "강한친구 대한육군\n강한친구 대한육군";
return 0;
}
방법 3
#include <stdio.h>
int main() {
printf("강한친구 대한육군\n강한친구 대한육군");
return 0;
}
https://www.acmicpc.net/problem/10171
방법 1
#include <iostream>
using namespace std;
int main() {
cout << "\\ /\\" << endl;
cout << " ) ( ')" << endl;
cout << "( / )" << endl;
cout << " \\(__)|" << endl;
return 0;
}
방법 2
#include <stdio.h>
int main() {
printf("\\ /\\\n");
printf(" ) ( ')\n");
printf("( / )\n");
printf(" \\(__)|\n");
return 0;
}
https://www.acmicpc.net/problem/10172
탈출문자 Escape Sequence
\ -> \\
" -> \"
방법 1
#include <iostream>
using namespace std;
int main() {
cout << "|\\_/|" << endl;
cout << "|q p| /}" << endl;
cout << "( 0 )\"\"\"\\" << endl;
cout << "|\"^\"` |" << endl;
cout << "||_/=\\\\__|" << endl;
return 0;
}
방법 2
#include <stdio.h>
int main() {
printf("|\\_/|\n");
printf("|q p| /}\n");
printf("( 0 )\"\"\"\\\n");
printf("|\"^\"` |\n");
printf("||_/=\\\\__|\n");
return 0;
}
https://www.acmicpc.net/problem/1000
방법 1
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a + b;
return 0;
}
방법 2
#include <stdio.h>
int main() {
int A, B;
scanf("%d %d", &A, &B);
printf("%d", A + B);
return 0;
}
https://www.acmicpc.net/problem/1001
방법 1
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a - b;
return 0;
}
방법 2
#include <stdio.h>
int main() {
int A, B;
scanf("%d %d", &A, &B);
printf("%d", A - B);
return 0;
}
https://www.acmicpc.net/problem/10998
방법 1
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a * b;
return 0;
}
방법 2
#include <stdio.h>
int main() {
int A, B;
scanf("%d %d", &A, &B);
printf("%d", A * B);
return 0;
}
https://www.acmicpc.net/problem/1008
방법 1
#include <iostream>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
cout.precision(10);
cout << a / b;
return 0;
}
방법 2
#include <stdio.h>
int main() {
double A, B;
scanf("%lf %lf", &A, &B);
printf("%.10lf", A / B);
return 0;
}
https://www.acmicpc.net/problem/10869
방법 1
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a + b << endl;
cout << a - b << endl;
cout << a * b << endl;
cout << a / b << endl;
cout << a % b << endl;
return 0;
}
방법 2
#include <stdio.h>
int main() {
int A, B;
scanf("%d %d", &A, &B);
printf("%d\n", A + B);
printf("%d\n", A - B);
printf("%d\n", A * B);
printf("%d\n", A / B);
printf("%d\n", A % B);
return 0;
}
https://www.acmicpc.net/problem/10430
방법 1
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
cout << (a + b)%c << endl;
cout << ((a%c)+(b%c))%c << endl;
cout << (a*b)%c << endl;
cout << ((a%c)*(b%c))%c << endl;
return 0;
}
https://www.acmicpc.net/problem/2588
방법 1
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int b100 = b / 100;
int b10 = b / 10 - b100 * 10; // b10 = ((b/10)%10) or ((b%100)/10)
int b1 = b % 10;
cout << a*b1 << endl;
cout << a*b10 << endl;
cout << a*b100 << endl;
cout << a*b << endl;
return 0;
}
방법 2
#include <iostream>
#include <string>
using namespace std;
int main() {
int a;
string b;
cin >> a >> b;
cout << a*(b[2] - '0') << endl; // char ascii b[2]='5'=53, '0'=48
cout << a*(b[1] - '0') << endl;
cout << a*(b[0] - '0') << endl;
cout << a*stoi(b) << endl;
return 0;
}