编写程序,从键盘输入一个三位数,求出其逆序数并输出,例如输入123,输出321.
问题描述:
编写程序,从键盘输入一个三位数,求出其逆序数并输出,例如输入123,输出321.
答
int main()
{
int n,n1,n2;
cin>>n1;
n2 = n1%100;
n1 = n1/100;
n = n1;
n2 = n2%10;
n1 = n1/10;
n = n + 10*n1 + 100*n2;
return n;
}