编程题:输入一个大于100的数,将数得百位,十位,个位依次拆分,再按照个位十位百位组成新的数(例如:输入456,输入654)
int n=456, a, b, c;
a = n % 10; // 个位
b = n / 10 % 10; // 十位
c = n / 100; // 百位
int m;
m = a * 100 + b * 10 + c;
循环求余10,结果累乘
#include <stdio.h>
int main()
{
int n,m=0;
scanf("%d",&n);
while(n>0)
{
m = m*10 + n%10;
n = n/10;
}
printf("%d",m);
return 0;
}