0

我想问一下,我制定了这个代码来解决一个问题,但是 count 似乎没有提供正确的值。

任何建议。任何帮助表示赞赏。谢谢。

#include<iostream.h>
#include<conio.h>
void main()
{
    int count;
    for(int a=1;a<125;a++)
        for(int m=1;m<125;m++)
            for(int n=1;n<125;n++)
            {
                if(a*(m+n+2)==249-m)
                {
                    cout<<"a = "<<a<<" m = "<<m<<" n = "<<n<<"\n";
                    count=count+1;
                }
            }
            cout<<"count = "<<count<<"\n";
            getch();
}
4

1 回答 1

6

你不初始化count. 记得设置int count = 0;

你的编译器会警告你,并省去调试或询问你是否只允许它的麻烦。(来自@chris)

于 2013-06-21T05:48:08.797 回答