Programming/C
[백준] 단계별로 풀어보기 > while문 (C언어)
코딩뽀시래기
2021. 3. 23. 17:32
728x90
+) 풀이 코드
https://github.com/jung0115/CodingTestPractice.git
GitHub - jung0115/CodingTestPractice: Practice Coding Test with Beakjoon, programmers, etc.
Practice Coding Test with Beakjoon, programmers, etc. - GitHub - jung0115/CodingTestPractice: Practice Coding Test with Beakjoon, programmers, etc.
github.com
10952번 - 2021.03.23.화
#include <stdio.h>
int main(void){
int A, B;
while(1){
scanf("%d %d", &A, &B);
if( A == 0 && B == 0)
break;
printf("%d\n", A+B);
}
return 0;
}
10951번 - 2021.03.23.화
#include <stdio.h>
int main(void){
int A, B;
while( scanf("%d %d", &A, &B) != EOF ){
printf("%d\n", A+B);
}
return 0;
}
-> 입력 중단 조건이 주어지지 않았을 때, 더이상 입력이 들어오지 않으면 반복문을 종료하도록 하는 방법.
1110번 - 2021.03.25.목
#include <stdio.h>
int main(void){
int N, M, cnt=0, tmp;
scanf("%d", &N);
M = N;
do{
tmp = (M/10) + (M%10);
M = ((M%10)*10) + (tmp%10);
cnt++;
} while( N != M );
printf("%d", cnt);
return 0;
}
728x90