将指定的某个正整数数逆序输出.c 293 B

12345678910111213141516171819
  1. #include <stdio.h>
  2. int main() {
  3. int m, reversed = 0;
  4. scanf("%d", &m);
  5. if (m < 0) {
  6. printf("error");
  7. } else {
  8. while (m > 0) {
  9. reversed = reversed * 10 + m % 10;
  10. m /= 10;
  11. }
  12. printf("%d", reversed);
  13. }
  14. return 0;
  15. }