study/EC.crew 정기 모임 정리
220808 Ec.crew
은솜솜솜
2022. 8. 8. 17:31
728x90
[ 2022년 8월 8일 정모 문제 풀이 모음 ]
#1.
해결
더하기 사이클(백준 1110번)
#include <stdio.h>
int main() {
int x,y,num1,num2,N1,N2;
int ans=0;
printf("정수 N을 입력하세요.");
scanf("%d", &x);
if(x<10) {
num1=0;
num2=x;
}
else {
num1=x/10;
num2=x%10;
}
while (1) {
ans++;
y=num1+num2;
if(y<10) {
N1=num2;
N2=y;
}
else {
N1=num2;
N2=y%10;
}
if(x == (N1*10) + N2){
break;
}
num1=N1;
num2=N2;
}
printf("\n\n%d",ans);
return 0;
}
728x90