| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4693 人关注过本帖
标题:为什么程序每个函数都出现同样的错误,missing ')' before identifier 'st'
只看楼主 加入收藏
暗静暗静呢
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2015-6-26
结帖率:50%
收藏
已结贴  问题点数:6 回复次数:1 
为什么程序每个函数都出现同样的错误,missing ')' before identifier 'st'
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#define N 7
struct student
{
char name[20];//姓名
char no[10];//学号
int math;//数学分数
int english;//英语分数
int computer;//计算机分数
int score;//交换用分数
int eveave;//个人平均分
};  
struct student st[N];         //定义学生结构体
void subject(student st[],int n)//选定某个学科进行分析
{
 
int number;
int temp;
printf("        请选择要分析的学科: ");
scanf("%d",&number);
int i=0;
switch(number)
{
case 1:
printf("     以下是关于数学的成绩分析:\n");
for(i=0;i<n;i++)
st[i].score=st[i].math;
break;
case 2:
printf("       以下是关于英语的成绩分析:\n");
for(i=0;i<n;i++)
st[i].score=st[i].english;

break;
case 3:
printf("      以下是关于计算机成绩分析:\n");
for(i=0;i<n;i++)
st[i].score=st[i].computer;
break;
}
int j;
printf("        按学号每个人的原始数据为:\n");
for(i=0;i<n;i++)
printf("        %d\n",st[i].score);
printf("        排序后的数据为\n");
for(i=0;i<n-1;i++)
{

for(j=0;j<n-i;j++)
if(st[j+1].score<st[j].score)
{
temp=st[j].score;
st[j].score=st[j+1].score;
st[j+1].score=temp;
}
}
for(i=0;i<n;i++)
printf("        %d\n",st[i].score);
printf("        该门课的平均成绩为:\n");
float sum=0;
float courseave;
for(i=0;i<n;i++)
{
sum=sum+st[i].score;
}
courseave=sum/7;
printf("        %f\n",courseave);
printf("        该门课的最高分为:\n");
int max=st[0].score;
for(i=0;i<n;i++)
{
if(st[i].score>max)
{
max=st[i].score;
}
}
printf("        %d\n",max);//最高分
printf("        该门课的最低分为:\n");
int min=st[0].score;
for(i=0;i<n;i++)
{
if(st[i].score<min)
{
min=st[i].score;
}
}
printf("        %d\n",min);//最低分
int bjg=0;
int jg=0;
int zd=0;
int lh=0;
int yx=0;
for(i=0;i<n;i++)
{
if(st[i].score<60)    //计算不及格人数
{
bjg++;
}
if(st[i].score>=60&&st[i].score<70)//计算60~69人数
{
jg++;
}
if(st[i].score>=70&&st[i].score<80)//计算70~79人数
{
zd++;
}
if(st[i].score>=80&&st[i].score<90)//计算80~89人数
{
lh++;
}
if(st[i].score>=90)//计算90分以上人数
{
yx++;
}
}
printf("        该门课的不及格人数为:\n        %d\n        60~69人数:\n        %d\n        70~79人数:\n        %d\n        80~89人数:\n        %d\n        90分以上人数:\n        %d\n",bjg,jg,zd,lh,yx);



}
void studentave(student st[],int n)//计算每个人的平均成绩并排序
{
int i;
int temp;
for(i=0;i<n;i++)
{
st[i].eveave=(st[i].math+st[i].english+st[i].computer)/4;
}
printf("        每个人平均成绩为:\n");
for(i=0;i<n;i++)   
printf("        %d\n",st[i].eveave);

for(i=0;i<n-1;i++)
{
for(int j=0;j<n-1-i;j++)
if(st[j].eveave>st[j+1].eveave)
{
temp=st[j].eveave;
st[j].eveave=st[j+1].eveave;
st[j+1].eveave=temp;
}
}
printf("        平均成绩排序为:\n");
for(i=0;i<n;i++)
printf("        %d\n",st[i].eveave);
}

void nosearch(student st[],int n)//按学号查找学生的各门成绩
{
int i=0;
n=7;
char no[10];
printf("        请输入要查找的学生号:");
scanf("%s",&no);
while(strcmp(no,st[i].no)==0&&i<n)
i++;
if(i==n)
{
printf("        meizhaodao\n");
}
else
printf("        %s\t%s\t%d\t%d\t%d\n",st[i].no,st[i].name,st[i].math,st[i].english,st[i].computer);
}
void namesearch(student st[],int n)//按姓名查找学生的各门成绩
{
int i=0;
n=7;
char name[20];
printf("        请输入要查找的姓名:");
scanf("%s",&name);
while(strcmp(name,st[i].name)==0&&i<7)
i++;
if(i==n)
{
printf("        meizhaodao\n");
}
else
printf("        %s\t%s\t%d\t%d\t%d\n",st[i].no,st[i].name,st[i].math,st[i].english,st[i].computer);
}
void cunchu(student st[],int n)    //存盘
{
int i;
FILE *fp;
fp=fopen("C:\\RJ\\input.dat","wb");//以"写"方式打开一个二进制文件
if(fp==NULL)
{
printf("Can't open!\n");
exit(0);
}

for(i=0;i<n;i++)
{
fwrite(&st[i],sizeof(struct student),1,fp);//一次写入一个学生的成绩
}
fclose(fp);
}
void duqu(student st[],int n)      //读取数据
{
int i;
FILE *fp;
fp=fopen("C:\\RJ\\input.dat","rb");//以"读"方式打开一个二进制文件
if(fp==NULL)   
{
printf("Can't open!\n");
exit(0);
}
for(i=0;i<7;i++)
{
fread(&st[0],sizeof(struct student),1,fp);//一次读取一个学生的成绩
printf("                  %s\t%s\t%d\t%d\t%d\n",st[i].no,st[i].name,st[i].math,st[i].english,st[i].computer);
}
fclose(fp);
}

void main()
{
int i;
struct student st[7]={  {"01","王芳",78,77,90},
{"02","张强",89,67,88},
{"03","李浩",56,66,78},
{"04","黄鹏",89,86,85},
{"05","尚校",67,88,76},
{"06","赵鹏",45,54,67},
{"07","蒋泽",78,76,70}};
printf(" 本题的实验数据为数据:\n");
cunchu(st,7);//存盘input.dat
duqu(st,7);//读取数据
printf("  对各科的成绩分析如下:\n");
printf("        本实验采取switch()语句,分别1~3中的表示不同的学科\n        输入1表示计算关于数学方面的成绩;\n        输入2表示计算关于英语方面的成绩;\n        输入3表示计算关于计算机方面的成绩;\n");
subject(st,7);//按各科成绩排序
subject(st,7);//按各科成绩排序
subject(st,7);//按各科成绩排序
printf("   关于个人平均成绩分析:\n");
studentave(st,7);//计算每个人的平均成绩并排序
printf("   按照不同条件查询分析:\n");
nosearch(st,7);//按学号查找学生的各门成绩
namesearch(st,7);//按姓名查找学生的各门成绩

}


错误:C:\Users\zgx\Desktop\Text1.c(16) : error C2146: syntax error : missing ')' before identifier 'st'
C:\Users\zgx\Desktop\Text1.c(16) : error C2061: syntax error : identifier 'st'
C:\Users\zgx\Desktop\Text1.c(16) : error C2059: syntax error : ';'
C:\Users\zgx\Desktop\Text1.c(16) : error C2059: syntax error : '['
C:\Users\zgx\Desktop\Text1.c(16) : error C2059: syntax error : ')'
C:\Users\zgx\Desktop\Text1.c(123) : error C2146: syntax error : missing ')' before identifier 'st'
C:\Users\zgx\Desktop\Text1.c(123) : error C2061: syntax error : identifier 'st'
C:\Users\zgx\Desktop\Text1.c(123) : error C2059: syntax error : ';'
C:\Users\zgx\Desktop\Text1.c(123) : error C2059: syntax error : '['
C:\Users\zgx\Desktop\Text1.c(123) : error C2059: syntax error : ')'
C:\Users\zgx\Desktop\Text1.c(150) : error C2146: syntax error : missing ')' before identifier 'st'
C:\Users\zgx\Desktop\Text1.c(150) : error C2061: syntax error : identifier 'st'
C:\Users\zgx\Desktop\Text1.c(150) : error C2059: syntax error : ';'
C:\Users\zgx\Desktop\Text1.c(150) : error C2059: syntax error : '['
C:\Users\zgx\Desktop\Text1.c(150) : error C2059: syntax error : ')'
C:\Users\zgx\Desktop\Text1.c(166) : error C2146: syntax error : missing ')' before identifier 'st'
C:\Users\zgx\Desktop\Text1.c(166) : error C2061: syntax error : identifier 'st'
C:\Users\zgx\Desktop\Text1.c(166) : error C2059: syntax error : ';'
C:\Users\zgx\Desktop\Text1.c(166) : error C2059: syntax error : '['
C:\Users\zgx\Desktop\Text1.c(166) : error C2059: syntax error : ')'
C:\Users\zgx\Desktop\Text1.c(182) : error C2146: syntax error : missing ')' before identifier 'st'
C:\Users\zgx\Desktop\Text1.c(182) : error C2061: syntax error : identifier 'st'
C:\Users\zgx\Desktop\Text1.c(182) : error C2059: syntax error : ';'
C:\Users\zgx\Desktop\Text1.c(182) : error C2059: syntax error : '['
C:\Users\zgx\Desktop\Text1.c(182) : error C2059: syntax error : ')'
C:\Users\zgx\Desktop\Text1.c(199) : error C2146: syntax error : missing ')' before identifier 'st'
C:\Users\zgx\Desktop\Text1.c(199) : error C2061: syntax error : identifier 'st'
C:\Users\zgx\Desktop\Text1.c(199) : error C2059: syntax error : ';'
C:\Users\zgx\Desktop\Text1.c(199) : error C2059: syntax error : '['
C:\Users\zgx\Desktop\Text1.c(199) : error C2059: syntax error : ')'
C:\Users\zgx\Desktop\Text1.c(228) : warning C4013: 'cunchu' undefined; assuming extern returning int
C:\Users\zgx\Desktop\Text1.c(229) : warning C4013: 'duqu' undefined; assuming extern returning int
C:\Users\zgx\Desktop\Text1.c(232) : warning C4013: 'subject' undefined; assuming extern returning int
C:\Users\zgx\Desktop\Text1.c(236) : warning C4013: 'studentave' undefined; assuming extern returning int
C:\Users\zgx\Desktop\Text1.c(238) : warning C4013: 'nosearch' undefined; assuming extern returning int
C:\Users\zgx\Desktop\Text1.c(239) : warning C4013: 'namesearch' undefined; assuming extern returning int
搜索更多相关主题的帖子: computer english include 计算机 before 
2016-12-12 17:31
bjut_Allen
Rank: 9Rank: 9Rank: 9
来 自:平乐园工业技术学校
等 级:蜘蛛侠
威 望:8
帖 子:323
专家分:1223
注 册:2016-10-16
收藏
得分:6 
typedef struct student
{
char name[20];//姓名
char no[10];//学号
int math;//数学分数
int english;//英语分数
int computer;//计算机分数
int score;//交换用分数
int eveave;//个人平均分
}student;  
student st[N];         //定义学生结构体

[此贴子已经被作者于2016-12-12 18:29编辑过]


Code is my life.
2016-12-12 17:48
快速回复:为什么程序每个函数都出现同样的错误,missing ')' before identifier ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013770 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved