[c++] 백준 4단계

알감자·2022년 3월 11일
0

백준알고리즘

목록 보기
4/52

#10952

#include <iostream>
using namespace std;

int main() 
{
	int A, B;

	while (1) {
		cin >> A >> B;

		if (A < 0 || A>10 || B < 0 || B>10) {
			return 0;
		}

		if (A == 0 && B == 0)
			break;

		cout << A + B << "\n";

	}
}

#1110

#include <iostream>
using namespace std;

int main() 
{
	int N, count = 0;
	int x, y, z = 0;
	cin >> N;

	z = N;
	
	if (N < 0 || N >99)
		return 0;

	while (1) {
		x = N / 10;
		y = N % 10;
		N = (N % 10) * 10 + (N / 10 + N % 10) % 10;
		
		count++;

		if (N == z)
			break;
	}

	cout << count;
}

0개의 댓글