标题:这个代码在wxdev中结果显示不正确而在vc++中能正确显示结果
取消只看楼主
wcy2754327
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-4-1
结帖率:0
已结贴  问题点数:20 回复次数:0 
这个代码在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;
}
搜索更多相关主题的帖子: 中能 wxdev 结果 代码 
2010-05-29 19:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-308651-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018853 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved