爱问知识人 爱问教育 医院库

如何根据成绩用电脑分班才均匀

首页

如何根据成绩用电脑分班才均匀

如何根据成绩用电脑分班才均匀

提交回答

全部答案

    2019-06-19 10:15:36
  •   #include<stdio。h>struct student{int num;//学号char name[20];//姓名float chengji1,chengji2,chengji3;//成绩float avg;//平均成绩} ;void display(struct  student stu[],int count);void paixu(struct  student stu[],int count);int  charu(struct  student stu[],int count);void shanchu(struct student stu[],int count);struct student Input();void main(){//声明结构数组struct  student stu[30];int count=0;//count用来表示数组的元素的个数char ch;printf("请输入学员信息:");do{stu[count]=Input();printf("是否继续?(y or n):");fflush(stdin);ch=getchar(); count++; }while(ch=='Y'||ch=='y');//输出显示函数printf("排序之前的数组为:\n");display(stu,count);printf("排序之后的数组为:\n");paixu(stu,count);display(stu,count);int count1=charu(stu,count);shanchu(stu,count1);printf("删除之后的数组为:\n");display(stu,count);}struct student Input()  {struct student stu;float sum=0;printf("\n学号:");scanf("%d",&stu。
      num);printf("\n姓名:");fflush(stdin);gets(stu。name);printf("\n请输入第1门课的成绩:");scanf("%f",&stu。
      chengji1);printf("\n请输入第2门课的成绩:");scanf("%f",&stu。chengji2);printf("\n请输入第3门课的成绩:");scanf("%f",&stu。
      chengji3);stu。avg=(stu。chengji1+stu。chengji2+stu。chengji3)/3;return stu;}void paixu(struct  student stu[],int count)//排序{struct  student temp;for(int i=0;i<count;i++){for(int j=0;j<count-i-1;j++) {if(stu[j]。
      avg<stu[j+1]。avg){temp=stu[j+1];stu[j+1]=stu[j];stu[j]=temp;}}}}int charu(struct student stu[],int count) //插入{     int i,j; char ch;     struct student t; printf("是否插入?(y or n):"); fflush(stdin); ch=getchar(); if(ch=='Y'||ch=='y') { printf("\n请输入要插入的学员信息:"); t=Input(); for(i=0;i<count;i++){ if(stu[i]。
      avg<t。avg)break; } for(j=count;j>=i;j--) { stu[j+1]=stu[j];  } stu[i]=t; printf("插入之后的数组为:\n"); printf("学号\t姓名\t平均成绩\n"); for(int i=0;i<count+1;i++) { printf("%d\t%s\t%。
      2f\n",stu[i]。num,stu[i]。name,stu[i]。avg); }} return count+1;}void shanchu(struct student stu[],int count) //删除{     int dno; int j,i; char ch; printf("是否删除?(y or n):"); fflush(stdin); ch=getchar(); if(ch=='Y'||ch=='y') { printf("\n请输入要删除的学员的学号:"); scanf("%d",&dno); for(i=0;i<count;i++) { if(stu[i]。
      num==dno)         break;  }  for(j=i;j<count-1;j++)  {  stu[j]=stu[j+1];  } }}void display(struct  student stu[],int count){printf("学号\t姓名\t平均成绩\n");for(int i=0;i<count;i++){printf("%d\t%s\t%。
      2f\n",stu[i]。num,stu[i]。name,stu[i]。avg);}}这是我以前做个的一个项目与之类似,你只要稍加改动就OK了。

    单***

    2019-06-19 10:15:36

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):