注册 登录
编程论坛 C++教室

一个简单的逻辑错误要问问大家

酷野 发布于 2007-03-31 23:03, 470 次点击

是个逻辑错误
现在我想要当输入0时输出over
但现在无论输入什么时都会继续循环DO语句里的内容
我要到达我想的目的应该怎么改正啊
#include<iostream>
#include<stdio.h>
#define max 100
using namespace std;
main()
{
int a[max],b;
do
{ cout<<"please enter 4 number:"<<endl;
cin>>a[1]>>a[2]>>a[3]>>a[4];
cout<<"enter 0 to quiz,other to continue"<<endl;
cin>>b;
}
while(b=0);
{
cout<<"over";
}
}

3 回复
#2
RL7202007-03-31 23:23
汗一个先。。。
while(b!=0)
后面那一对括号{}没必要加。。。。

by the way.. 是quit不是quiz..
#3
cpluslover2007-04-01 00:00

或者改为
b=0------------------------------------b!=0

[此贴子已经被作者于2007-4-1 0:02:08编辑过]

#4
fox0000022007-04-01 01:39
#include<stdio.h>
---------------------
汗,#include<iostream>不就行了。难道lz是c->c++
1