#include
using namespace std;
int main()
{
int a, b, c;
int count = 0;
for (a = 0; a <= 34; a++)
for (b = 0; b <= 50; b++)
for (c = 0; b <= 200; c++)
if((3*a+2*b+0.5*c ==100.0)&&(a+b+c==100));
{
cout << "a=" << a << "b=" << b << "c=" << c<<endl ;
count++;
}
cout << "There are" << count << "methods.\n";
return 0;
}
你应该是想求一下 符合两个式子的a、b、c的情况是吗?
#include<iostream> //少了<iostream> ,没有头文件怎么运行啊。。。
using namespace std;
int main()
{
//你应该是想求一下 符合两个式子的a、b、c的情况吧
int a, b, c;
int count = 0;
for (a = 0; a <= 34; a++)
for (b = 0; b <= 50; b++)
for (c = 0; c <= 200; c++) //这里应该写 c<=200 的,你写错了
if((3*a+2*b+0.5*c ==100.0)&&(a+b+c==100))//; 这里多了一个 ; 号 if成为空方法体了,尴尬
{
cout << "a=" << a << " b=" << b << " c=" << c<<endl ; //空格一下吧,不然看起来太紧密
count++;
}
cout << "There are " << count << " methods.\n";//这里也空格一下
return 0;
}