设为首页 加入收藏

TOP

C++编程实例学生成绩排名系统(一)
2014-07-19 22:52:07 来源: 作者: 【 】 浏览:408
Tags:编程 实例 学生 成绩 排名 系统

  //文件读取需要自己在电脑中添加相应的文件名称

  #include

  #include

  #include

  #include

  #include

  using namespace std;

  void showmeanu();

  void add(struct student *a,int *n); //添加函数

  void del(struct student *a,int *n); //删除函数

  void change(struct student *a,int n); //修改函数

  void search1(struct student *a,int n); //查询单个函数

  void allrank(struct student *a,int n); //排序所有信息

  void printfall(struct student *a,int n); //打印所有信息

  void printf1(struct student *a,int n); //打印单个信息

  void mutirank(struct student *a,int n); //多重排名函数

  void ffprintf(struct student *a,int n); //写入函数

  void fail(struct student *a,int n);

  struct student

  {

  char number[15];

  char name [15];

  int c;

  int math;

  int gym;

  int all;

  int english;

  };

  int main()

  {

  struct student a[50];

  int n=0,i=0;

  char m;

  int flag=0;

  printf(" 欢迎来到学生成绩排名系统\n");

  printf(" 请选择你要执行的项目\n");

  FILE *fp;

  fp=fopen("H:\\student.txt","r");

  if(fp==NULL)

  {

  printf("文件读取失败\n");

  exit(1);

  }

  int k;

  i=0;

  while(( fscanf(fp,"%d%s%s%d%d%d%d%d",&k,a[i].number,a[i].name,&a[i].c,&a[i].math,&a[i].english,&a[i].gym,&a[i].all))!=EOF)

  i++;

  fclose(fp);

  n=i;

  while(1)

  {

  system("cls");

  showmeanu();

  m=getch();

  switch(m)

  {

  case '1':

  add(a,&n);

  break;

  case '2':

  if(n==0)

  {

  printf("亲,还没有联系人呢,按1添加联系人\n");

  break;

  }

  change(a,n);

  break;

  case '3':

  if(n==0)

  {

  printf("亲,还没有联系人呢,按1添加联系人\n");

  break;

  }

  del(a,&n);

  break;

  case '4':

  if(n==0)

  {

  printf("亲,还没有联系人呢,按1添加联系人\n");

  break;

  }

  search1(a,n);

  printf("\n");

  break;

  case '5':

  if(n==0)

  {

  printf("亲,还没有联系人呢,按1添加联系人\n");

  break;

  }

  printfall(a,n);

  char k;

  printf("按任意键返回……………………\n");

  k=getch();

  break;

  case '6':

  if(n==0)

  {

     

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇OC类方法学习简介 下一篇野指针的成因与避免方法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C语言指针从入门到基 (2025-12-26 05:21:36)
·【C语言指针初阶】C (2025-12-26 05:21:33)
·C语言指针的定义和使 (2025-12-26 05:21:31)
·在 Redis 中如何查看 (2025-12-26 03:19:03)
·Redis在实际应用中, (2025-12-26 03:19:01)