[Bronze_I] 정답 비율 46%
https://www.acmicpc.net/problem/1110
if (cycle==0)
cycle = 1 )문제가 쉬워서 크게 배운 점은 없었다. 복잡한 연산은 함수로 만들어 분리하면 가독성에 도움이 된다 정도 ?
#include <stdio.h>
int calculate(int num){
int new=0;
if(num<10)
new = num;
else
new = (num/10 + num%10)%10;
new += (num%10)*10;
return new;
}
int main(void){
int cycle = 0;
int input = 0;
int temp=0;
scanf("%d", &input);
while(input != temp){
if(cycle == 0)
temp = calculate(input);
else
temp = calculate(temp);
cycle++;
}
if(cycle==0)
cycle = 1;
printf("%d", cycle);
return 0;
}