//解释都在注释里,个人认为写的还算清晰
AC代码:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
int reverse(int num)//数字逆序函数
{
int rev = 0;
while (num)
{
rev = 10 * rev + num % 10;
num /= 10;
}
return(rev);
}
int ispalin(int j)//判断是否是回文的函数
{
if (reverse(j) == j)
{
return(1);
}
return (0);
}
int main()
{
int a;
cin >> a;
while (a!=0)
{
cout << a << "+" << reverse(a) <<"="<< a + reverse(a);
a = a + reverse(a);
cout << endl;//由于输入的第一个是否是回文都要进行一次操作,就单独提出来了,话说是不是能用do while来着...
while (ispalin(a) == 0)//根据题目要求的格式进行回文操作
{
cout << a << "+" << reverse(a) <<"="<< a + reverse(a);
a = a + reverse(a);
cout << endl;
}
cin >> a;
}
//system("pause");
return 0;
}