您好,欢迎来电子发烧友网! ,新用户?[免费注册]

您的位置:电子发烧友网>源码下载>数值算法/人工智能>

成绩排名源代码

大小:155 人气: 2010-02-09 需要积分:0
{$username}的空间

用户级别:注册会员

贡献文章:

贡献资料:

成绩排名源代码
#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 { printf("input No.%d:",i+1);
   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 {printf("%-10s%-14s%8.2f%8.2f%8.2f%8.2f\n",code[i],name[i],
  score1[i],score2[i],score3[i],aver[i]);
  }
}
 

非常好我支持^.^

(1) 100%

不好我反对

(0) 0%

      发表评论

      用户评论
      评价:好评中评差评

      发表评论,获取积分! 请遵守相关规定!