C语言 遇到了 [Error] expected primary-expression before '[' token 求解啊
#include<stdio.h>structstudent{intnum;charname;charsex;floatmath;floatenglish;floatpo...
#include<stdio.h>
struct student
{
int num;
char name;
char sex;
float math;
float english;
float politics;
};
int main()
{
float average(float a,float b,float c);
struct student person[4];
int search(int k,struct person[4]);
int i,k,j;
for(i=0;i<4;i++)
{
printf("please input num,name,sex,and the math's,english's,politics's points:");
scanf("%d %s %s %f %f %f",&person[i].num,&person[i].name,&person[i].sex,&person[i].math,&person[i].english,&person[i].politics);
}
printf("please input the num:");
scanf("%d",&k);
j=search(k,struct person[4]);
printf("%d %s %s %f %f %f\n",person[j].num,person[j].name,person[j].sex,person[j].math,person[j].english,person[j].politics);
printf("the average grade is :%f",average(person[j].math,person[j].english,person[j].politics));
return 0;
}
int search(int k,struct person[4])
{
int i;
for(i=0;i<4;i++)
{
if(k==person[i].num)
break;
}
return i;
}
float average(float a,float b,float c)
{
return (a+b+c)/3;
} 展开
struct student
{
int num;
char name;
char sex;
float math;
float english;
float politics;
};
int main()
{
float average(float a,float b,float c);
struct student person[4];
int search(int k,struct person[4]);
int i,k,j;
for(i=0;i<4;i++)
{
printf("please input num,name,sex,and the math's,english's,politics's points:");
scanf("%d %s %s %f %f %f",&person[i].num,&person[i].name,&person[i].sex,&person[i].math,&person[i].english,&person[i].politics);
}
printf("please input the num:");
scanf("%d",&k);
j=search(k,struct person[4]);
printf("%d %s %s %f %f %f\n",person[j].num,person[j].name,person[j].sex,person[j].math,person[j].english,person[j].politics);
printf("the average grade is :%f",average(person[j].math,person[j].english,person[j].politics));
return 0;
}
int search(int k,struct person[4])
{
int i;
for(i=0;i<4;i++)
{
if(k==person[i].num)
break;
}
return i;
}
float average(float a,float b,float c)
{
return (a+b+c)/3;
} 展开
1个回答
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询