코드
package backjun_while;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class while_1110_1 {
public static void main(String[] args) throws Exception, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
StringBuilder sb = new StringBuilder();
int N = Integer.parseInt(br.readLine());
int count = 0;
int copy = N;
do {
N = ((N%10)*10)+(((N/10)+(N%10))%10);
count++;
}
while(copy!=N);
System.out.println(count);
}
}
또 다른 코드
package backjun_while;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class while_1110 {
public static void main(String[] args) throws Exception, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int a = N/10; //10의자리수
int b = N%10; //1의 자리수
int c;
int count = 0;
while(true) {
count++;
c = b;
b = (a+b)%10;
a = c;
if(N == a*10+b) {
break;
}
}System.out.println(count);
}
}
두개 입니다.
구글링해서 얻은 2개구요
이해하면서 다시 코드입력해봤어요
가장 이해하기 어려웠던거는 십의 자리수와 일의 자리수 만들어내는 것이였습니다.