请用C++编写下面程序
来源:百度知道 编辑:UC知道 时间:2024/06/30 23:56:09
编写一个函数Inverse(int n)可以把正整数n及其各个位上的数字逆序输出,例如:n=2375,输出为5732
参考代码:
#include <iostream>
using namespace std;
void Inverse(int n)
{
int d;
do
{
d = n % 10;
cout << d;
n /= 10;
} while (n > 0);
cout << endl;
}
void main()
{
for (int i = 1234; i < 2345; i += 8)
{
cout << i << '\t';
Inverse(i);
}
}
VC6编译成功并通过详细调试o(∩_∩)o
#include <iostream>
using namespace std;
long int x;
int a ,b, c, d, e;
void Inverse (int x)
{
//cin>>x;
if (x<0||x>99999)
{cout<<"输入无效!\n";}
else
if (x>10000)
{ cout<<endl;
cout<<"您输入的一个5位整数";
a=(int)x/10000;
b=(int)(x-10000*a)/1000;
c=(int)(x-10000*a-1000*b)/100;
d=(int)(x-10000*a-1000*b-100*c)/