문제 : http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=110502&format=html
Status : Solved
#include <iostream>
using namespace std;
unsigned int reverse(unsigned int input);
int main(void)
{
unsigned int numberOfTestcase, input, i;
cin >> numberOfTestcase;
for(i = 0; i < numberOfTestcase; i++)
{
int count = 0;
cin >> input;
if(input == reverse(input))
{
cout << 0 << " " << input << endl;
}
else
{
while((input = input + reverse(input)) != reverse(input))
{
count++;
}
cout << ++count << " " << input << endl;
}
}
return 0;
}
unsigned int reverse(unsigned int input)
{
unsigned int result = 0;
while(input > 0)
{
result *= 10;
result += input % 10;
input = input / 10;
}
return result;
}