做个解鸡兔同笼的程序,加了个while,结果就提示[Error] expected primary-expression before '{' token,望大神帮忙解决。
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e,f,g;
cout<<"问笼中两动物各几只请按1 退出请按2"<<endl;
cin>>g;
while
{
if(g==1)
{
cout<<"[动物一脚数必须比动物二脚数小]"<<endl;
cout<<"脚的数量?"<<endl;
cin>>a;
cout<<"头的数量?"<<endl;
cin>>b;
cout<<"动物一脚数?"<<endl;
cin>>e;
cout<<"动物二脚数?"<<endl;
cin>>f;
d=(a-(b*2))/(f-e);
c=b-d;
cout<<"动物一的只数="<<c<<" "<< "动物二的只数="<<d<<endl;
}
cout<<"是否继续运行?";
cin>>g;
if(g=2)
{
return 0;
}
}
}