출제 링크 : https://www.acmicpc.net/problem/1110
1110번: 더하기 사이클
0보다 크거나 같고, 99보다 작거나 같은 정수가 주어질 때 다음과 같은 연산을 할 수 있다. 먼저 주어진 수가 10보다 작다면 앞에 0을 붙여 두 자리 수로 만들고, 각 자리의 숫자를 더한다. 그 다음,
www.acmicpc.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Solution
{
class Program
{
static void Main(string[] args)
{
int First_Number = int.Parse(Console.ReadLine());
int Last_Number = First_Number;
int Cycle = 0;
bool repeat = true;
while(repeat)
{
int Tens = Last_Number / 10;
int Units = Last_Number % 10;
int Sum = Tens + Units;
int Result = Sum % 10;
Last_Number = (Units * 10) + Result;
Cycle++;
if (First_Number == Last_Number) break;
}
Console.WriteLine(Cycle);
}
}
}
'Baekjoon 문제풀이' 카테고리의 다른 글
[Baekjoon 5단계(2)] 2562번 : 최댓값 (0) | 2021.09.02 |
---|---|
[Baekjoon 5단계(1)] 10818번 : 최소, 최대 (0) | 2021.09.01 |
[Baekjoon 4단계(2)] 10951번 : A+B - 4 (0) | 2021.09.01 |
[Baekjoon 4단계(1)] 10952번 : A+B - 5 (0) | 2021.08.31 |
[Baekjoon 3단계(11)] 10871번 : X보다 작은 수 (0) | 2021.08.31 |