刚学C++。请人帮改个程序
题目是:要求输入一个不多于5位的正整数,要求输出:1求出是几位数,2分别输出各位上的数字,3按逆序输出该数,例如123,输出321。下面是我自己写的,做错了~谁能给改下,或写个给我,谢谢了
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int s,i,j;
int m=0;
cout<<"please enter the number"<<'\n';
cin>>s;
while(s>99999||s<0)
{
cout<<"data error,enter again";
cin>>s;
}
cout<<"各位数字分别是:";
for (i=1;(i<5)&&((s/10)!=0);)
{
j=s%10;
cout<<j<<",";
s=s/10;
m=m+10*exp(i-1)*j; i++;
}
if((s/10)==0) cout<<s;
cout<<"逆序数是:"<<m<<'\n'<<"位数是:"<<i<<endl;
return 0;
}