Problem K: 反序数
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 485 Solved: 290
[ Submit][ Status][ Web Board]
Description
编制一个函数reverse,返回给定数据的“反序数”,例如输入1234,输出4321。
Input
一个正整数
Output
该数的反序数
Sample Input
1234
Sample Output
4321
HINT
在下面代码的基础上完成。
#include <iostream>
using namespace std;
int main()
{
int m,n;
cin>>m;
n=reverse(m);
cout<<n<<endl;
return 0;
}
int reverse(int x) //函数只管求值,不管输出。输出由main函数完成
{ }
//C代码
#include<stdio.h>
#include<string.h>
int main()
{
char a[99];
int n,i;
gets(a);
n=strlen(a);
for(i=n-1;i>=0;i--)
{
printf("%c",a[i]);
}
printf("\n");
return 0;
}