南京浦口石佛寺驾校:一道简单的C++作业题

来源:百度文库 编辑:中科新闻网 时间:2024/05/02 08:41:28
诸位高手帮帮小弟我~
虽然是英文的,但是都很简单,整个程序也异常简单,只要用最简单的语句即可实现,感激不尽

First, write a function that receives any non-negavive int, and returns an int whose value is the digits of the received value in reversed order. Then write a driver program to test the function.

Examples:Reverse(123)==321
Reverse(Reverse(123))==123

You should not use a string to solve this problem!
因为我们不是计算机专业,所以问的问题可能不是很清楚,很抱歉,下面做一下补充
题目只是编一段程序,要求输入一个非负数,然后让它的顺序反过来,做为返回值,输出返回值即可(我是这样理解)
如此而已

我怎么发现计算机专业总是自以为是,你看不懂,我怎么看的懂!呵呵。我不想多说了!
给出代码如下:
int main()
{
int a=0;
int num=456;
printf("\nnum=%d",num);
while (num!=0)
{
a=a*10+num%10;
num=num/10;
}
printf("\nReverse(num)=%d",a);
return 0;
}
调试已经通过!呵呵。
结果显示:
num=456
Reverse(num)=654
哈哈。你自己试试!注释我就不写了,代码就几行字!呵呵,看不懂,我也就没法子了!

我不想告诉你
但我不得不说
你不会说话
你怎么不说的清楚一点
虽然我是计算机专业的

这个俺不会啊