C语言高手请进!!!(还有追加分~~~~~~)

[复制链接]
查看11 | 回复3 | 2005-12-14 17:50:47 | 显示全部楼层 |阅读模式
#include #include #define StuMax 60
/* Max Students Num */#define ClsMax 10
/* Max Classes Num */#define ScorePass 60#define ScoreWell 80typedef struct{
float average;
/* Average of this Class */
float maxscore; /* Max Score */
float minscore; /* Min Score */
float perpass;
/* Percentage of Passed Students */
float perwell;
/* Percentage of Done well */} Class;typedef struct{
float scores[ClsMax];} Student;/* Global Variables */Student students[StuMax];Class classes[ClsMax];int stunum, clsnum; /* count of students, count of classes */void fillrecords(){
int i, j;
for(i = 0; iclasses.maxscore)
classes.maxscore = students[j].scores;
if(students[j].scores = ScorePass)
classes.perpass++;/* Passed num ++ */
if(students[j].scores >= ScoreWell)
classes.perwell++;/* Done well num ++ */
}
/* output information of this class */
printf("\n Statistics of Class %0d", i+1);
printf("\n\t Average: %f", classes.average / stunum);
printf("\n\t MaxScore : %f", classes.maxscore);
printf("\n\t MinScore : %f", classes.minscore);
printf("\n\t PerPass: %f%", classes.perpass / (stunum * 100));
printf("\n\t PerWell: %f%", classes.perwell / (stunum * 100));
}}int main(){
printf("\nNumber of Students: ");
scanf("%d", stunum);
/* Validating required, do it yourself */
printf("\nNumber of Classes : ");
scanf("%d", clsnum);
/* Validating required, do it yourself */
fillrecords(); operaterecords(); getch();
return 0;}没有对输入的合法性进行判断,你自己搞定吧
回复

使用道具 举报

千问 | 2005-12-14 17:50:47 | 显示全部楼层
# include stdlib.h"struct stu{float max; float min; float aver; float pass; float excel;};main(){int m,n; float *a; struct stu *b; int i,j; foat max,min,aver=0,pass,excel; scanf("%d%d",&m,&n); a=(float *)malloc(sizeof(float)*m*n); b=(struct stu*)malloc(sizeof(struct stu)*n);for(i=0;ia[j]) min=a[j];if(a[j]>=60) b.pass++;if(a[j]>=85) b.excel++;b.aver=b.aver+a[j];}aver=aver/m;b.pass=b.pass/m;b.excel=b.excel/m;}
for(i=0;i#include #define EX 90/*优秀*/#define PS 60/*及格*/typedef struct _course{
int data;
struct _course *pNext;}COURSE,*PCOURSE;typedef struct _student{
COURSE data;
struct _student *pNext;}STUDENT,*PSTUDENT;int main(char* x ,char** y){
PSTUDENT student,ps,pst;
PCOURSE course,pc,pct;
int m,n,i,j,k,av=0,max=0,min=0;float ex=.0,pass=.0;
printf("Now start input data:\n");
printf("Input student num:\n");
scanf("%d",&m);
printf("Input student course num:\n");
scanf("%d",&n);
pst=ps=student;
for(i=0;idata));
pct=pc;
pct=pct->pNext;
}
ps->data=course;
pst=ps;
pst=pst->pNext;
}
ps=student;
for(j=0;jdata;
for(k=0;kpNext;
}
av=av+pc->data;
if(maxdata)max=pc->data;
if(min>pc->data)min=pc->data;
if(EXdata)ex++;
if(PSdata)pass++;
ps=ps->pNext;
}
printf("#%d course av:%d,max:%d,min:%d,pass:%f,ex:%f\n",av/m,max,min,pass/m,ex/m);
ps=student;
}}
回复

使用道具 举报

千问 | 2005-12-14 17:50:47 | 显示全部楼层
没有用到类???
回复

使用道具 举报

千问 | 2005-12-14 17:50:47 | 显示全部楼层
main(){ float sc[100][50]; int m,n; int i,j; float avg,max,min; float pass,exc; float average(float sc[][],int m,int j); float maxsc(float sc[][],int m,int j); float minsc(float sc[][],int m,int j); float passrate(float sc[][],int m,int j); float excrate(float sc[][],int m,int j); printf("Please input M:"); scanf("%d",&m); printf("Please input N:"); scanf("%d",&n); printf("Please input all the scores:"); for(i=0;imax)
max=sc[j];return max;} float minsc(float sc[100][50],int m,int j){float min;int i;min=sc[0][j];for(i=1;i=60)
count+=1; pass=count/m; return pass;} float excrate(float sc[100][50],int m,int j){int count,i; float exc; count=0; for(i=0;i=90)
count+=1; exc=count/m; return exc;}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行