日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

我的编程生涯的入门语言 - C语言之学员成绩管理

發(fā)布時間:2025/3/15 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 我的编程生涯的入门语言 - C语言之学员成绩管理 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

至今還保存著當(dāng)初學(xué) C語言 時的代碼,現(xiàn)在看來已經(jīng)有點(diǎn)生疏,畢竟好久沒玩了。

往事不堪回首啊!

直接貼代碼了:

#include <stdio.h> struct student {int num;char name[15];float score[3];double avr; }; struct student stu[50]; struct student input() {struct student studn;int i,sum=0;printf ("請輸入學(xué)號:");scanf ("%d",&studn.num);printf ("請輸入姓名:");scanf("%s",&studn.name);for(i=0;i<3;i++){printf ("第%d 個成績:",i+1);scanf ("%f",&studn.score[i]);sum+=studn.score[i];}studn.avr=sum/3.0;return studn; } void display(struct student stud[],int count) {printf ("\n學(xué)號\t姓名\t平均成績\n");for (int i=0;i<count;i++){printf ("%d",stud[i].num);printf ("\t%s",stud[i].name);printf ("\t%7.2f",stud[i].avr);printf ("\n");} } void sort (struct student stud[],int count) {struct student t;for (int i=0;i<count;i++){for (int j=0;j<count-i-1;j++){if ((stud[j].avr)<(stud[j+1].avr)){t=stud[j];stud[j]=stud[j+1];stud[j+1]=t;}}} }void insert (struct student stud[],int count) {int i,j;struct student temp;printf ("請輸入要插入學(xué)員的信息\n");temp = input();for(i=0;i<count;i++){if((stud[i].avr)<(temp.avr))break;}for (j=count;j>=i;j--){stud[j+1]=stud[j];}stud[i]=temp; } void display2(struct student stud[],int count) {printf ("\n學(xué)號\t姓名\t平均成績\n");for (int i=0;i<(count+1);i++){printf ("%d",stud[i].num);printf ("\t%s",stud[i].name);printf ("\t%7.2f",stud[i].avr);printf ("\n");} } void dele (struct student stud[],int count ) {int i,j,temp;//struct student temp;printf ("請輸入要刪除的學(xué)員的學(xué)號:\n");scanf ("%d",&temp);// temp=input();for (i=0;i<count;i++){if (stud[i].num==temp){for (j=i;j<count;j++){stud[j]=stud[j+1];}}} }void main() {int count=0;char ch='Y';while((ch=='y')||(ch=='Y')){stu[count]=input();count++;printf ("是否要繼續(xù)(y/n):\n");fflush(stdin);scanf ("%c",&ch);}printf ("\n排序前的學(xué)員成績序列如下:");display(stu,count);sort (stu,count);printf ("排序后的學(xué)員成績序列如下:");display (stu,count);insert(stu,count);printf ("插入后的學(xué)員成績序列如下:");display2 (stu,count);dele(stu,count+1);display (stu,count); }

  

謝謝瀏覽!

轉(zhuǎn)載于:https://www.cnblogs.com/Music/archive/2012/03/10/c-language-learners-performance-management.html

總結(jié)

以上是生活随笔為你收集整理的我的编程生涯的入门语言 - C语言之学员成绩管理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。