22/10/31

CJB_ny·2022년 10월 31일
0

공부 요약

목록 보기
25/38
post-thumbnail

백준

진행한 문제

2020, 1110, 10952, 2884, 14681, 1330

1110 더하기 사이클 부분

	int start = 0;
	cin >> start;
	int temp = start;
	int count = 0;
	
	while(true)
	{
		int first = (temp / 10) % 10;
		int second = temp % 10;
		temp = ((temp % 10) * 10) + ((first + second) % 10);

		++count;

		if (temp == start)
			break;
	}

	cout << count << endl;

한가지 알아야할 점이 10으로 나누면 실수값이 나오는데 뒤에 나머지 연산자로 계산해주면 정수부분 반환을 해준다

win32API

profile
https://cjbworld.tistory.com/ <- 이사중

0개의 댓글