64,646
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a;
long dvin = 0;
long mc;
long ini_val;
int preset=0;
do
{
cout <<"Please enter a integer between 99999 to 1:" <<endl;
cin >> ini_val;
}
while(ini_val <0||ini_val>99999);
mc=ini_val;
while(mc)
{
++preset;
mc/=10;
}
mc=ini_val;
for(int i=0;i<preset;i++) //局部变量未初始值
{
a=mc%10;
dvin+=a*pow((float)10,(float)(preset-i-1)); ///pow
mc/=10;
}
cout << preset <<endl;
cout <<"The begin_value is:" <<ini_val <<endl;
cout <<"The dvin_value is:" <<dvin;
return 0;
}