以下程序在 init()中出现declaration syntax error ,请高手帮我解答一下,(因长度限制,部分方法没写)

#include<stdio.h>#include<stdlib.h>typedefstructprocess{intneed[10];intallocation[5];... #include<stdio.h>
#include<stdlib.h>
typedef struct process{
int need[10];
int allocation[5];
int request[5];
int finish;
}
init(struct process p[])
{ p[0].allocation[0]=0;p[0].allocation[0][1]=1;p[0].allocation[0][2]=0;
p[1].allocation[0]=2;p[1].allocation[1]=0;p[1].allocation[2]=0;
p[2].allocation[0]=3;p[2].allocation[1]=0;p[2].allocation[2]=2;
p[3].allocation[0]=2;p[3].allocation[1]=1;p[3].allocation[2]=1;
p[4].allocation[0]=0;p[4].allocation[1]=0;p[4].allocation[2]=2;
p[0].need[0]=7;p[0].need[1]=4;p[0].need[2]=3;
p[1].need[0]=1;p[1].need[1]=2;p[1].need[2]=2;
p[2].need[0]=6;p[2].need[1]=0;p[2].need[2]=0;
p[3].need[0]=0;p[3].need[1]=1;p[3].need[2]=1;
p[4].need[0]=4;p[4].need[1]=3;p[4].need[2]=1;

p[0].finish=0;p[1].finish=0;p[2].finish=0;
printf("there are 5 processes and 3 resources,the datas are as follow:\n");
printf(" max allocation need available\n");
printf(" A B C A B C A B C A B C\n");
printf("p0 7 5 3 0 1 0 7 4 3 3 3 2\n");
printf("p1 3 2 2 2 0 0 1 2 2\n");
printf("p2 9 0 2 3 0 2 6 0 0\n");
printf("p3 2 2 2 2 1 1 0 1 1\n");
printf("p4 4 3 3 0 0 2 4 3 1\n");
}
int request(struct process p[],int b,int available[]){
int i,j,k;
printf("now input the number of the resource\n");
scanf("%d%2d%2d%2d",&n,&i,&j,&k);

p[b].request[0]=i;p[b].request[1]=j;p[b].request[2]=k;
for(int h=0;h<3;h++){
if(p[b].request[h]>p[b].need[h])
return 0;
else if(p[b].request[h]>available[h])
printf("not enough resource,please wait\n");
else{
for(int a=0;a<3;a++){
available[a]-=p[b].request[a];
p[b].need[a]-=p[b].request[a];
p[b].allocation[a]+=p[b].request[a];

}}
} return;}
。。。。。
main(){
struct process p[5]; int available[5]; int work[5];
available[0]=3;available[1]=3;available[2]=2;
work[0]=0;work[1]=0;work[2]=0;

int b;int s;
init(p);
printf("input the process of you need\n");
scanf("%d",&b);
s=request( p,b,available);
if(s!=0) security(p,b,work,available);
}


展开
 我来答
kaixingui2012
2013-04-27 · TA获得超过4.2万个赞
知道大有可为答主
回答量:1.4万
采纳率:81%
帮助的人:7792万
展开全部
typedef struct process{
int need[10];
int allocation[5];
int request[5];
int finish;
} PROC ; //一、typedef是定义一个新的变量类型,你少了类型名PROC(假定)
//二、这里少个分号,typedef结尾要有分号

typedef 用法:
typedef 现有变量类型 新变量类型;
追问
我可不可以把我的程序发给你,你帮我改下,如果可以,实在感激不尽!
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式