C語言學(xué)生成績(jī)管理系統(tǒng)源碼
更新時(shí)間:2022年03月02日 09:27:30 作者:reg183
這篇文章主要為大家詳細(xì)介紹了C語言學(xué)生成績(jī)管理系統(tǒng)源碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了C語言學(xué)生成績(jī)管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
效果如下:

代碼如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student{
? ? ? ? int num;
? ? ? ? char name[20];
? ? ? ? float score1;
? ? ? ? float score2;
? ? ? ? float score3;
? ? ? ? double total;
}stu[4];
void a();
void b();
void c();
void d();
void e();
int main(void)
{
? ? //printf("Hello World!\n");
? ? ? ?int n;
? ? ? ?while(n!=6){
? ? ? ? ? ?printf("\t student score manage system\n");
? ? ? ? ? ?printf("1-input all student's score!\n");
? ? ? ? ? ?printf("2-show all student's score!\n");
? ? ? ? ? ?printf("3-output student's average score!\n");
? ? ? ? ? ?printf("4-output student's score and rank!\n");
? ? ? ? ? ?printf("5-result output txt file!\n");
? ? ? ? ? ?printf("6-exit!\n");
? ? ? ? ? ?scanf("%d",&n);
? ? ? ? ? ?switch(n){
? ? ? ? ? ? ? ?case 1:a();break;
? ? ? ? ? ? ? ?case 2:b();break;
? ? ? ? ? ? ? ?case 3:c();break;
? ? ? ? ? ? ? ?case 4:d();break;
? ? ? ? ? ? ? ?case 5:e();break;
? ? ? ? ? ? ? ?case 6:printf("******ByeBye******");break;
? ? ? ? ? ?}
? ? ? ?}
? ? return 0;
}
//輸入成績(jī)
void a(){
? ? int i;
? ? for(i=0;i<4;i++){
? ? ? ? printf("input num name score1 score2 score3: ");
? ? ? ? scanf("%d%s%f%f%f",&stu[i].num,stu[i].name,&stu[i].score1,&stu[i].score2,&stu[i].score3);
? ? }
? ? for(i=0;i<4;i++){
? ? ? ? stu[i].total=stu[i].score1+stu[i].score2+stu[i].score3;
? ? }
}
//輸出成績(jī)
void b(){
? ? int i;
? ? printf("num \t name \t score1 \t score2 \t score3 \t total \n");
? ? for(i=0;i<4;i++){
? ? ? ? printf("%d \t %s \t %f \t %f \t %f \t %f \n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].total);
? ? }
}
//求平均成績(jī)
void c(){
? ? double total=0;
? ? double avg;
? ? int i;
? ? for(i=0;i<4;i++){
? ? ? ? total+=stu[i].total;
? ? }
? ? avg=total/4.0;
? ? printf("avg is :%f \n",avg);
}
//按照總成績(jī)排序
void d(){
? ? struct student temp;
? ? int i,j;
? ? for(i=0;i<4;i++){
? ? ? ? for(j=i+1;j<4;j++){
? ? ? ? ? ? temp=stu[i];
? ? ? ? ? ? stu[i]=stu[j];
? ? ? ? ? ? stu[j]=temp;
? ? ? ? }
? ? }
? ? printf("num \t name \t score1 \t score2 \t score3 \t total \n");
? ? for(i=0;i<4;i++){
? ? ? ? printf("%d \t %s \t %f \t %f \t %f \t %f \n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].total);
? ? }
}
// 保存數(shù)據(jù)到文件
void e(){
? ? int i;
? ? FILE *fp;
? ? fp=fopen("E:/result.txt","w");
? ? fprintf(fp,"num \t name \t score1 \t score2 \t score3 \t total \n");
? ? for(i=0;i<4;i++){
? ? ? ? fprintf(fp,"%d \t %s \t %f \t %f \t %f \t %f \n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].total);
? ? }
? ? printf(" save success! \n ");
}以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- C語言編寫學(xué)生成績(jī)管理系統(tǒng)
- 學(xué)生成績(jī)管理系統(tǒng)C語言代碼實(shí)現(xiàn)
- C語言利用結(jié)構(gòu)體數(shù)組實(shí)現(xiàn)學(xué)生成績(jī)管理系統(tǒng)
- C語言學(xué)生成績(jī)管理系統(tǒng)源代碼
- C語言實(shí)現(xiàn)學(xué)生成績(jī)管理系統(tǒng)實(shí)戰(zhàn)教學(xué)
- C語言實(shí)現(xiàn)簡(jiǎn)單學(xué)生成績(jī)管理系統(tǒng)
- C語言結(jié)構(gòu)體版學(xué)生成績(jī)管理系統(tǒng)
- C語言實(shí)現(xiàn)學(xué)生成績(jī)管理系統(tǒng)
- C語言學(xué)生成績(jī)管理系統(tǒng)課程設(shè)計(jì)
- C語言學(xué)生成績(jī)管理系統(tǒng)設(shè)計(jì)
相關(guān)文章
錯(cuò)誤:sem_union的存儲(chǔ)大小未知問題的解決方法
這篇文章主要介紹了錯(cuò)誤:sem_union的存儲(chǔ)大小未知問題的解決方法,需要的朋友可以參考下2016-10-10
C++11新特性“=default”,“=delete”的使用
=default、=delete 是C++11的新特性,分別為:顯式缺省(告知編譯器生成函數(shù)默認(rèn)的缺省版本)和顯式刪除(告知編譯器不生成函數(shù)默認(rèn)的缺省版本),本文就來介紹一下如何使用2021-05-05
用c語言實(shí)現(xiàn)冒泡排序,選擇排序,快速排序
本篇文章是對(duì)使用c語言實(shí)現(xiàn)冒泡排序,選擇排序,快速排序的代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05
FFmpeg獲取網(wǎng)絡(luò)攝像頭數(shù)據(jù)解碼
這篇文章主要為大家詳細(xì)介紹了FFmpeg獲取網(wǎng)絡(luò)攝像頭數(shù)據(jù)解碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-06-06

