零钱换整钱C语言,帮忙讲一下用while语句为什么错误

2025-04-01 07:27:36
推荐回答(1个)
回答1:

int main(int argc, char* argv[])
{
int x,y,z;
cout<<"test 1 - 100"< for(int i=1;i<100;++i)
{
bool run=true;
for(x=1;x<100*i&&run;++x)
for(y=1;y<20*i&&run;++y)
for(z=1;z<10*i&&run;++z)
{
if(18*x == 15*y && 15*y==20*z && (x+5*y+10*z)==100*i)
run=false;
}
if(!run)
cout< else cout<<" not ok:"< }
}
测试发现是80元的整数倍