这个代码在wxdev中结果显示不正确而在vc++中能正确显示结果
#include<string>#include<cmath>
using namespace std;
int main() {
cout<<"input a number:";
int i;
int sum=0;
double pwr=0;
cin>>i;
if(i<10) {
if(i%9==0)
cout<<"is";
else
cout<<"is not";
}
else
{
while(i/(static_cast<int>(pow(10,pwr)))>=10)
pwr++;
cout<<pwr<<endl;
while(pwr>=0) {
int j;
j=i/(static_cast<int>(pow(10,pwr)));
i=i%(static_cast<int>(pow(10,pwr)));
pwr--;
sum+=j;
cout<<"j="<<j<<endl;
}
cout<<"sum="<<sum<<endl;
if((sum%9)==0)
cout<<"这个数能被9整除";
else
cout<<" is not";
}
system("pause");
return 0;
}