Reverse Numbers in C: Simple Code
Here is a simple C program that can reverse the output of the individual digits of an integer.
#include <stdio.h>
void reverse(int n) {
if (n < 10) {
printf("%d", n);
} else {
printf("%d", n % 10);
reverse(n / 10);
}
}
int main() {
int num;
printf("请输入一个整数:");
scanf("%d", &num);
printf("逆序输出的数字为:");
reverse(num);
return 0;
}
This program defines a function called reverse, which recursively outputs the individual digits of an integer in reverse order. In the main function, the user inputs an integer and then calls the reverse function to output the individual digits of the integer in reverse order.