https://www.acmicpc.net/problem/10952
방법 1
#include <iostream>
using namespace std;
int main() {
int A, B;
while (1) {
cin >> A >> B;
if (A == 0 & B == 0)
break;
cout << A + B << "\n";
}
}
방법 2
#include<stdio.h>
int main(){
int a,b;
while(1){
scanf("%d %d",&a,&b);
if(a==0 && b==0) break;
printf("%d\n",a+b);
}
}
https://www.acmicpc.net/problem/10951
방법 1 - bool overloading
#include <iostream>
using namespace std;
int main() {
int A, B;
while (cin >> A >> B) {
cout << A + B << "\n";
}
}
방법 2
#include <iostream>
using namespace std;
int main() {
int A, B;
while (!(cin >> A >> B).eof()) {
cout << A + B << "\n";
}
}
방법 3
#include <iostream>
using namespace std;
int main() {
int A, B;
while (cin.eof() == true) {
cout << A + B << "\n";
}
}
방법 4
#include<stdio.h>
int main(){
int a,b;
while(scanf("%d %d",&a,&b) != EOF)
printf("%d\n",a+b);
}
https://www.acmicpc.net/problem/1110
방법 1
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N;
int count = 0;
int init = N;
while (1) {
count++;
A = N / 10;
B = N % 10;
N = 10 * B + (A + B) % 10;
if (init == N)
break;
}
cout << count;
}
방법 2
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int A, cnt = 0, init = N;
do {
cnt++;
N = 10 * (N % 10) + (N / 10 + N % 10) % 10;
} while (N != init);
cout << cnt;
}
방법 3
#include<stdio.h>
int main(){
int n, init, cnt=0;
scanf("%d",&n);
init=n;
do{
cnt++;
n=(n%10)*10+(n/10+n%10)%10;
}
while(n!=init);
printf("%d",cnt);
}