1 //逆转一个整数,如123->321 2 #include<stdio.h> 3 #include<stdlib.h> 4 5 int main(int argc, char *argv[]) 6 { 7 int ival; 8 int sum; 9 while(printf("input the number:\n"),scanf_s("%d",&ival) == 1) 10 { 11 sum = 0; 12 while(ival) 13 { 14 sum = sum * 10 + ival % 10; 15 ival /= 10; 16 } 17 printf("The reverse number is:%d\n",sum); 18 } 19 system("pause"); 20 return 0; 21 }
时间: 2024-10-06 19:21:08