c语言编程高手请进!

#include"stdio.h"structstudent{intnumber;charname[15];floatenglish;floatmath;floatc;}... #include "stdio.h"
struct student
{int number;
char name[15];
float english;
float math;
float c;
}stu[10]={{01,"aaa",99.0,100.0,82.0},
{02,"aab",85.0,90.0,100.0},
{03,"aac",99.0,99.0,45.0},
{04,"aad",85.0,45.0,78.0},
{05,"aae",99.0,100.0,100.0},
{06,"aaf",65.0,85.0,25.0},
{07,"aag",80.0,100.0,98.0},
{08,"aah",78.0,98.0,96.0},
/* {09,"aai",78.0,98.0,98.0},
{10,"aao",100.0,100.0,100.0}*/};
/*
float average11()
{int i;
float average1,sum1;
sum1=sum1+stu[i].math;
average1=sum1/10;
return average1;
}
float average22()
{int i;
float average2,sum2;
sum2=sum2+stu[i].english;
average2=sum2/10;
return average2;
}
float average33()
{int i;
float average3,sum3;
sum3=sum3+stu[i].english;
average3=sum3/10;
return average3;
}
float maxx()
{int i;
float max;
max=stu[i],math;
for(i=0;i<10;i++)
if(max=stu[i].math)
max=stu[i],math;
return max;
}
float minn()
{int i;
float min;
min=stu[i],english;
for(i=0;i<10;i++)
if(min>stu[i].english)
min=stu[i],english;
return min;
}
int countt()
{int i,count=0;
c
if(stu[i].c==100)
count++;
return count;
}
*/
main()
{int i;
/*float max,min,average1,average2,average3;
int i,count=0;
max=maxx();
min=minn();
average1=average11();
average2=average22();
average3=average33();
count=countt() */
printf("number num english math c\n");
for(i=0;i<10;i++)
printf("%d %s %f %f %f \n",stu[i].number,stu[i].name,stu[i].english,stu[i].math,stu[i].c);
/* printf("average\n");
printf("%f,%f,%f\n",average1,average2,average3);
printf("shuxuezuidazhi\n");
printf("%f\n",max);
printf("yingyuzuixiaozhi\n");
printf("%f\n",min);
printf("cyuyanmanfen\n");
printf("%d\n",count);*/
}
帮我检查下错误!并能运行!
展开
 我来答
天棄
2008-06-13
知道答主
回答量:41
采纳率:0%
帮助的人:18.7万
展开全部
你这个程序要达到的目的是求出所有各学科的平均分、数学的最高分,英语最低分,以及满分的人数,程序中/*...*/之间的东西是注释,不进行编译的,再就是第三个求平均分的函数里面也许是你输入错误?应当是求stu[i].c的分吧,再就是把点号写成逗号,或语句结束没加分号等,具体改正说明见如下注释,希望能对你有所帮助。
#include "stdio.h"
struct student
{int number;
char name[15];
float english;
float math;
float c;
}stu[10]={{01,"aaa",99.0,100.0,82.0},
{02,"aab",85.0,90.0,100.0},
{03,"aac",99.0,99.0,45.0},
{04,"aad",85.0,45.0,78.0},
{05,"aae",99.0,100.0,100.0},
{06,"aaf",65.0,85.0,25.0},
{07,"aag",80.0,100.0,98.0},
{08,"aah",78.0,98.0,96.0},
{09,"aai",78.0,98.0,98.0},
{10,"aao",100.0,100.0,100.0}}; /*定义一个结构体数组并赋值,此处的注释符号不要的*/
float average11() /*求数学科目的平均分*/
{int i;
float average1=0,sum1=0; /*定义变量还得初始化呀*/
for(i=0;i<10;i++)/*要用个类似for循环语句求所有的数学分之和*/
sum1=sum1+stu[i].math;
average1=sum1/10;
return average1;
}
float average22() /*求英语科目的平均分*/
{int i;
float average2=0,sum2=0; /*定义变量还得初始化呀*/
for(i=0;i<10;i++)/*要用个类似for循环语句求所有的英语分之和*/
sum2=sum2+stu[i].english;
average2=sum2/10;
return average2;
}
float average33() /*求c科目的平均分*/
{int i;
float average3=0,sum3=0; /*定义变量还得初始化呀*/
for(i=0;i<10;i++)/*要用个类似for循环语句求所有的c分之和*/
sum3=sum3+stu[i].c; /*此处应当是求c的平均数吧?*/
average3=sum3/10;
return average3;
}
float maxx() /*求数学科目的最高分*/
{int i;
float max;
max=stu[0].math; /*stu[0].math里面应当是符号.不是逗号,将第一个数学分赋予max*/
for(i=1;i<10;i++) /*此处i初始值改为1,即从第二个数学分开始和第一个数学分比较大小*/
if(max<stu[i].math)
max=stu[i].math; /*stu[i].math里面应当是符号.不是逗号,*/
return max;
}
float minn() /*求英语科目的最低分*/
{int i;
float min;
min=stu[0].english; /*stu[0].english里面应当是符号.不是逗号,将第一个英语分赋予min*/
for(i=1;i<10;i++) /*此处i初始值改为1,即从第二个英语分开始和第一个英语分比较大小*/
if(min>stu[i].english)
min=stu[i].english; /*stu[0].english里面应当是符号.不是逗号,*/
return min;
}
int countt() /*统计c科目满分100的个数*/
{int i,count=0;
for(i=0;i<10;i++) /*使用循环语句啊!*/
if(stu[i].c==100)
count++;
return count;
}
/*还是注释符号的问题*/
main()
{int i,count;/* 重复定义i干吗呢?*/
float max,min,average1,average2,average3; /*还是注释符号的问题*/
max=maxx();
min=minn();
average1=average11();
average2=average22();
average3=average33();
count=countt();/*还是注释符号的问题,且语句后面要以分号;结束呀*/
printf("number name english math c\n"); /*num应当是name吧!*/
for(i=0;i<10;i++)
printf("%d %s %f %f %f \n",stu[i].number,stu[i].name,stu[i].english,stu[i].math,stu[i].c);
printf("average\n"); /*还是注释符号的问题*/
printf("%f,%f,%f\n",average1,average2,average3);
printf("shuxuezuidazhi\n");
printf("%f\n",max);
printf("yingyuzuixiaozhi\n");
printf("%f\n",min);
printf("cyuyanmanfen\n");
printf("%d\n",count);/*还是注释符号的问题*/
}
神圣的时刻
推荐于2016-04-30 · TA获得超过1421个赞
知道小有建树答主
回答量:1150
采纳率:0%
帮助的人:393万
展开全部
switch后面少{

所有CASE后面应该加: 不是 ;

同样,DEFAULT 后面也是 : 不是;

而且,你的这里:
default;
wo[k++]=s[i++];

else
break;
}
return 0;
}
也不对,RETURN 0上面的}位置错了,应该是:
default;
wo[k++]=s[i++];
}
else
break;

return 0;
}
不过,其实这里不需要再写个
else
break;
直接打个空语句就可以了。

最后,你少了个} 因为你的 }是用来结束while 的

另外有个错误(因为不知道你的意图):if(strcmp(a,m[j])==1)
这里,strcmp是指后者减去前者的差,如果是一样的话,值应该是0
也许你因该改成if(strcmp(a,m[j])==0)

这个你看看可以不?
#include<stdio.h>
#include<string.h>
int add(char a[])

{
int j;

char *m[10]={"one","two","three","four","five","six","seven","eight","nine","zero"};

for(j=0;j<=9;j++)

if(strcmp(a,m[j])==1)

return j;
}

int main()
{
int i,a=0,b=0,k=0;
char s[100],wo[50]={'\0'};
while(1)
{
gets(s);

if(s[0]!='0')
for(i=0;s[i]!='\0'; )

switch(s[i])
{
case ' ':
{wo[k]='\0';
a=a*10+add(wo);
b=b+a;
a=0;
i++;
break;
}
case '+':
{wo[k]='\0';
a=a+10+add(wo);
b=b+a;
a=0;
i++;
break;
}
case '=':
{printf("%d",b);
break;}
default:
wo[k++]=s[i++];
}
;

return 0;
}
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
高金山
2008-06-13 · TA获得超过1万个赞
知道大有可为答主
回答量:4101
采纳率:0%
帮助的人:1655万
展开全部
在你这个基础上,修改好了,能运行出结果!

#include "stdio.h"

struct student
{
int number;
char name[15];
float english;
float math;
float c;
}stu[10]={
{1,"aaa",99.0,100.0,82.0},
{2,"aab",85.0,90.0,100.0},
{3,"aac",99.0,99.0,45.0},
{4,"aad",85.0,45.0,78.0},
{5,"aae",99.0,100.0,100.0},
{6,"aaf",65.0,85.0,25.0},
{7,"aag",80.0,100.0,98.0},
{8,"aah",78.0,98.0,96.0},
{9,"aai",78.0,98.0,98.0},
{10,"aao",100.0,100.0,100.0}};

float average11()
{
int i;
float average1,sum1=0;

for(i=0;i<10;i++)
{
sum1=sum1+stu[i].math;
}
average1=sum1/10;
return average1;
}

float average22()
{
int i;
float average2,sum2=0;

for(i=0;i<10;i++)
{
sum2=sum2+stu[i].english;
}
average2=sum2/10;
return average2;
}
float average33()
{
int i;
float average3,sum3=0;

for(i=0;i<10;i++)
{
sum3=sum3+stu[i].english;
}
average3=sum3/10;
return average3;
}

float maxx()
{
int i;
float max;

max=stu[0].math;
for(i=0;i<10;i++)
if(max=stu[i].math)
max=stu[i].math;
return max;
}

float minn()
{
int i;
float min;

min=stu[0].english;
for(i=0;i<10;i++)
if(min>stu[i].english)
min=stu[i].english;
return min;
}

int countt()
{
int i,count=0;

for(i=0;i<10;i++)
if(stu[i].c==100)
count++;
return count;
}

main()
{
float max,min,average1,average2,average3;
int i,count=0;

max=maxx();
min=minn();
average1=average11();
average2=average22();
average3=average33();
count=countt();
printf("number num english math c\n");
for(i=0;i<10;i++)
printf("%d %s %f %f %f \n",stu[i].number,stu[i].name,stu[i].english,stu[i].math,stu[i].c);
printf("average\n");
printf("%f,%f,%f\n",average1,average2,average3);
printf("shuxuezuidazhi\n");
printf("%f\n",max);
printf("yingyuzuixiaozhi\n");
printf("%f\n",min);
printf("cyuyanmanfen\n");
printf("%d\n",count);
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
席正祥03
2008-06-13 · 超过24用户采纳过TA的回答
知道答主
回答量:72
采纳率:0%
帮助的人:76.4万
展开全部
#include <stdio.h>

struct student
{
int number;
char name[15];
float english;
float math;
float c;
};

float Average(student st[],char *subject)
{
float sum=0;
if ("math"==subject||"Math"==subject) //Math
{
for (int i=0;i<10;i++)
{
sum+= st[i].math;
}
}
else if ("English"==subject||"english"==subject) //English
{
for (int i=0;i<10;i++)
{
sum+= st[i].english;
}
}
else if ("C"==subject||"c"==subject) //C成绩
{
for (int i=0;i<10;i++)
{
sum+= st[i].c;
}
}
else //都不是,置0
{
return 0;//
}
return (sum/10);//返回平均成绩
}

float MaxMin(student st[],char *subject,char *valueType)
{
float maxS,minS;
if ("math"==subject||"Math"==subject)
{
minS=st[0].math;
maxS=st[0].math;//
for (int i=1;i<10;i++)
{
if (st[i].math>maxS)
{
maxS=st[i].math;
}
if (st[i].math<minS)
{
minS=st[i].math;
}
}
}
else if ("English"==subject||"english"==subject)
{
minS=st[0].english;
maxS=st[0].english;//
for (int i=1;i<10;i++)
{
if (st[i].english>maxS)
{
maxS=st[i].english;
}
if (st[i].english<minS)
{
minS=st[i].english;
}
}
}
else if ("C"==subject||"c"==subject)
{
minS=st[0].c;
maxS=st[0].c;//
for (int i=1;i<10;i++)
{
if (st[i].c>maxS)
{
maxS=st[i].c;
}
if (st[i].c<minS)
{
minS=st[i].c;
}
}
}
else
{
return 0;
}
//-----------------------------------
if (valueType=="max"||valueType=="Max")
{
return maxS;
}
else if (valueType=="min"||valueType=="Min")
{
return minS;
}
else
{
return 0;
}
}

void main()
{
struct student stu[]={
{1,"aaa",99.0,100.0,82.0},
{2,"aab",85.0,90.0,100.0},
{3,"aac",99.0,99.0,45.0},
{4,"aad",85.0,45.0,78.0},
{5,"aae",99.0,100.0,100.0},
{6,"aaf",65.0,85.0,25.0},
{7,"aag",80.0,100.0,98.0},
{8,"aah",78.0,98.0,96.0},
{9,"aai",76.0,96.0,98.0},
{10,"aaj",100.0,100.0,100.0}
};
printf("--------------AvgValue------------\n");
printf(" Math:%f\n English:%f\n C:%f\n",Average(stu,"Math"),Average(stu,"English"),Average(stu,"C"));
printf("--------------MaxValue------------\n");
printf(" Math:%f\n English:%f\n C:%f\n",MaxMin(stu,"Math","max"),MaxMin(stu,"English","max"),MaxMin(stu,"C","max"));
printf("--------------MinValue------------\n");
printf(" Math:%f\n English:%f\n C:%f\n",MaxMin(stu,"Math","min"),MaxMin(stu,"English","min"),MaxMin(stu,"C","min"));
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式