baekjoon 1110

호진·2022년 5월 24일
0

https://www.acmicpc.net/problem/1110


Idea

나누기 연산과 나머지 연산을 잘 이용합시다


Code

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int n, count = 0, temp = 0;
	int units = 0, tens = 0;
	
	scanf("%d", &n);

	int res = n;

	while (1) {
		tens = res / 10;
		units = res % 10;
			

		temp = tens + units;		
		if (temp >= 10) {
			temp %= 10;
		}

		res = (units * 10) + temp;

		count++;
		
		if (n == res) {
			break;
		}			
	}

	printf("%d", count);

	return 0;
}
profile
💭(。•̀ᴗ-)✧

0개의 댓글