成绩排名源代码
大小:155 人气: 2010-02-09 需要积分:0
标签:源代码(65730)
成绩排名源代码#include "stdio.h"
#include "stdlib.h"
#define N 5
void input(char *code[],char *name[],float *score1,float *score2,
float *score3,float *aver,int n);
void output(char *code[],char *name[],float *score1,float *score2,
float *score3,float *aver,int n,int j);
void sort(char *code[],char *name[],float *score1,float *score2,
float *score3, float *aver,int n);
void swap1(float *p1,float *p2);
void swap2(char **p1,char **p2);
main()
{char *code[N],*name[N];
float score1[N],score2[N],score3[N],aver[N];
input(code,name,score1,score2,score3,aver,N);
printf("\n");
output(code,name,score1,score2,score3,aver,N,1);
sort(code,name,score1,score2,score3,aver,N);
printf("\n");
output(code,name,score1,score2,score3,aver,N,2);
getch();
}
void input(char *code[],char *name[],float *score1,float *score2,
float *score3,float *aver,int n)
{int i;
for (i=0;i
code[i]=malloc(8);
name[i]=malloc(12);
scanf("%s%s%f%f%f",code[i],name[i],&score1[i],&score2[i],&score3[i]);
aver[i]=(score1[i]+score2[i]+score3[i])/3.0;
}
printf("\n");
}
void output(char *code[],char *name[],float *score1,float *score2,
float *score3,float *aver,int n,int j)
{int i;
printf(" school report(%d) \n",j);
printf("----------------------------------------------------------------\n");
printf("code name score1 score2 score3 aver\n");
printf("----------------------------------------------------------------\n");
for (i=0;i
score1[i],score2[i],score3[i],aver[i]);
}
}
非常好我支持^.^
(1) 100%
不好我反对
(0) 0%