expected primary-expression before '[' token 枚举类型总是出现这个错误,当然我程序还没编完 40

#include<iostream.h>#include<string.h>#include<windows.h>#include<time.h>typedefenumP... #include<iostream.h>
#include<string.h>
#include<windows.h>
#include<time.h>

typedef enum Phstate{thinking,waiting,eating};
Phstate phstate[5];
typedef enum Stickstate{used,nused};
Stickstate stickstate[5];
int stick[5];
int Ph[5];
int i,m;

void deadclock();
void ordered_allocation_philosopher();
void pre_allocation_philosopher();
void pre_hungry();
void quit();
void take();

int main(int argc,char*argv[])
{
int a;
x:cout<<"\n\n\n\n"
"\t\t\t@*******哲学家死锁问题*************@\n"
"\t\t\t$__________________________________$\n"
"\t\t\t$ 请选择操作(1-5) $\n"
"\t\t\t$__________________________________$\n"
"\t\t\t$ 1--死锁现象演示 $\n"
"\t\t\t$ 2--按序分配法防止死锁 $\n"
"\t\t\t$ 3--预分配法防止死锁 $\n"
"\t\t\t$ 4--防止饿死现象演示 $\n"
"\t\t\t$ 5--退出系统 $\n"
"\t\t\t$----------------------------------$\n"
"\t\t\t@**********************************@\n"<<endl;
cin>>a;
switch (a){
case '1':
deadclock();break;
case '2':
ordered_allocation_philosopher();break;
case '3':
pre_allocation_philosopher();break;
case '4':
pre_hungry();break;
case '5':
quit();break;
default:
goto x;
}
system("pause");
}
void take()
{
cout<<"申请左边筷子"<<endl;
if(Stickstate[i] == nused)
{
Stickstate[i] == used;
cout<<"拿起左边筷子"<<endl;
}
cout<<"申请右边筷子"<<endl;
if(Stickstate[i-1] == nused)
{
Stickstate[i-1] == used;
cout<<"拿起右边筷子"<<endl;
}

}
void deadclock()
{

for(i=0;i<5;i++)
{
if(i%2 == 0])
{
Phstate[i] == thinking;
Stickstate[i] == nused;
{
cout<<"第"<<i<<"位哲学家处于思想状态"<<endl;
}
}
else
{
Phstate[i] == waiting;
Stickstate[i] == nused;
cout<<"第"<<i<<"位哲学家处于等待状态"<<endl;
take();
}
}
}
展开
 我来答
匿名用户
2011-12-21
展开全部
#include<iostream.h>
#include<string.h>
#include<windows.h>
#include<time.h>

typedef enum Phstate{thinking,waiting,eating};
Phstate phstate[5];
typedef enum Stickstate{used,nused};
Stickstate stickstate[5];
int stick[5];
int Ph[5];
int i,m;

void deadclock();
void ordered_allocation_philosopher();
void pre_allocation_philosopher();
void pre_hungry();
void quit();
void take();

int main(int argc,char*argv[])
{
int a;
x:
cout<<"\n\n\n\n"
"\t\t\t@*******哲学家死锁问题*************@\n"
"\t\t\t$__________________________________$\n"
"\t\t\t$ 请选择操作(1-5) $\n"
"\t\t\t$__________________________________$\n"
"\t\t\t$ 1--死锁现象演示 $\n"
"\t\t\t$ 2--按序分配法防止死锁 $\n"
"\t\t\t$ 3--预分配法防止死锁 $\n"
"\t\t\t$ 4--防止饿死现象演示 $\n"
"\t\t\t$ 5--退出系统 $\n"
"\t\t\t$----------------------------------$\n"
"\t\t\t@**********************************@\n"<<endl;
cin>>a;
switch (a){
case '1':
deadclock();break;
case '2':
ordered_allocation_philosopher();break;
case '3':
pre_allocation_philosopher();break;
case '4':
pre_hungry();break;
case '5':
quit();break;
default:
goto x;
}
system("pause");
}
void take()
{
cout<<"申请左边筷子"<<endl;
if(stickstate[i] == nused)
{
stickstate[i] == used;
cout<<"拿起左边筷子"<<endl;
}
cout<<"申请右边筷子"<<endl;
if(stickstate[i-1] == nused)
{
stickstate[i-1] == used;
cout<<"拿起右边筷子"<<endl;
}

}
void deadclock()
{

for(i=0;i<5;i++)
{
if(i%2 == 0)
{
phstate[i] == thinking;
stickstate[i] == nused;
{
cout<<"第"<<i<<"位哲学家处于思想状态"<<endl;
}
}
else
{
phstate[i] == waiting;
stickstate[i] == nused;
cout<<"第"<<i<<"位哲学家处于等待状态"<<endl;
take();
}
}
}
百度网友6c4d48956
2011-12-24 · 超过40用户采纳过TA的回答
知道小有建树答主
回答量:104
采纳率:0%
帮助的人:111万
展开全部
if(i%2 == 0]) 多了一个]

手误,,细心呀
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式