學(xué)生成績管理系統(tǒng)-vs匯編_第1頁
學(xué)生成績管理系統(tǒng)-vs匯編_第2頁
學(xué)生成績管理系統(tǒng)-vs匯編_第3頁
學(xué)生成績管理系統(tǒng)-vs匯編_第4頁
學(xué)生成績管理系統(tǒng)-vs匯編_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

學(xué)習(xí)-----好資料#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <dos.h>#include <string.h>#define LENsizeof (struct student)#define FORMAT"%-8d%-15s%-12.1lf%-12.1lf%-12.1lf%-12.1lf\n"#define DATAstu[i].num,stu[i].name,stu[i].elec,stu[i].expe,stu[i].requ,stu[i].sumfloat Ielec,Iexpe,Irequ;float Felec,Fexpe,Frequ;struct student /*定義學(xué)生成績結(jié)構(gòu)體 */{int num;/*學(xué)號(hào)*/charname[15]; /*姓名*/doubleelec; /*選修課*/doubleexpe;/*實(shí)驗(yàn)課*/doublerequ; /*必修課*/doublesum;/*總分*/};struct studentstu[50]; /*定義結(jié)構(gòu)體數(shù)組 */void input(); /*錄入學(xué)生成績信息 */void show(); /*顯示學(xué)生信息 */void sort(); /*按總分排序*/void del(); /*刪除學(xué)生成績信息 */void modify(); /*修改學(xué)生成績信息 */void menu(); /*主菜單*/void insert(); /*插入學(xué)生信息 */void total(); /*計(jì)算總?cè)藬?shù) */void search(); /*查找學(xué)生信息 */main(){int n;menu();scanf("%d",&n);while(n){switch(n){case1:input(); break;case2:search(); break;case3:del(); break;case4:modify(); break;case5:insert(); break;case6:sort(); break;case7:total(); break;default : break;}menu();scanf("%d",&n);更多精品文檔學(xué)習(xí)-----好資料}}void show(){FILE*fp;int i,m=0;fp=fopen( "d:\\data.txt" ,"ab+");while(!feof(fp)){if(fread(&stu[m],LEN,1,fp)==1)m++;}fclose(fp);printf("numbernameelectiveexperimentrequiredsum\t\n");for(i=0;i<m;i++){printf(FORMAT,DATA); /*將信息按指定格式打印 */}}voidmenu(){system("cls");printf("\n");printf("\n");printf("\t|--------------------Studentmanagementsystem--------------------|\n");printf("\t||\n");printf("\t|0.exit|\n");printf("\t||\n");printf("\t|1.inputrecord|\n");printf("\t||\n");printf("\t|2.searchrecord|\n");printf("\t||\n");printf("\t|3.deleterecord|\n");printf("\t||\n");printf("\t|4.modifyrecord|\n");printf("\t||\n");printf("\t|5.insertrecord|\n");printf("\t||\n");printf("\t|6.order|\n");printf("\t||\n");printf("\t|7.number|\n");printf("\t||\n");printf("\t|-----------------------------------------------------------------|\n");printf("\n");printf("\n");printf("choose(0~7):");}voidinput(){更多精品文檔學(xué)習(xí)-----好資料inti,m=0;charch[2];FILE*fp;if((fp=fopen("d:\\data.txt","ab+"))==NULL)/*打開指定文件*/{printf("cannotopen\n");return;/*返回主函數(shù)*/}while(!feof(fp))/*feof()函數(shù)是用來判斷指針是否已經(jīng)到達(dá)文件尾部的,若指針指向文件末尾,則返回值為“真”,返回。*/{if(fread(&stu[m],LEN,1,fp)==1)m++;/*統(tǒng)計(jì)當(dāng)前記錄條數(shù)*/}fclose(fp);if(m==0)printf("Norecord!\n");else{system("cls");show();/*調(diào)用show函數(shù),顯示原有信息*/}if((fp=fopen("d:\\data.txt","wb"))==NULL){printf("cannotopen\n");return;}for(i=0;i<m;i++)fwrite(&stu[m],LEN,1,fp);/*向指定磁盤文件寫入信息*/printf("pleaseinput(y/n):/n");scanf("%s",&ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0){printf("pleaseinputpercentum:");printf("\nelective:");scanf("%f",&Ielec);printf("/nexperiment:");scanf("%f",&Iexpe);printf("/nrequiredcourse:");scanf("%f",&Irequ);}while(strcmp(ch,"y")==0||strcmp(ch,"Y")==0){printf("number:");scanf("%d",&stu[m].num);/*輸入學(xué)生學(xué)號(hào)*/for(i=0;i<m;i++)if(stu[i].num==stu[m].num){printf("thenumberisexisting,pressanytocontinue!");更多精品文檔學(xué)習(xí)-----好資料getch();fclose(fp);return ;}printf( "name:");scanf("%s",&stu[m].name); /*輸入學(xué)生姓名 */printf( "elective:" );scanf("%lf",&stu[m].elec); /*輸入選修課成績 */printf( "experiment:" );scanf( "%lf",&stu[m].expe); /*輸入實(shí)驗(yàn)課成績 */printf( "requiredcourse:" );scanf("%lf",&stu[m].requ); /*輸入必修課成績 */stu[m].sum=stu[m].elec*Ielec+stu[m].expe*Iexpe+stu[m].requ*Irequ; /*計(jì)算出總成績*/if(fwrite(&stu[m],LEN,1,fp)!=1) /*將新錄入的信息寫入指定的磁盤文件 */{printf( "cannotsave!" );getch();}else{printf( "%ssaved!\n" ,stu[m].name);m++;}printf( "continue?(y/n):" ); /*詢問是否繼續(xù) */scanf("%s",ch);}fclose(fp);printf( "OK!\n" );}void search() /*自定義查找函數(shù) */{FILE*fp;int snum,i,m=0;charch[2];if((fp=fopen( "d:\\data.txt" ,"ab+"))==NULL){printf( "cannotopen\n" );return ;}while(!feof(fp))if(fread(&stu[m],LEN,1,fp)==1)m++;if(m==0){printf( "norecord!\n" );return ;}更多精品文檔學(xué)習(xí)-----好資料printf( "pleaseinputthenumber:" );scanf("%d",&snum); /*輸入需要查找學(xué)生的學(xué)號(hào) */for(i=0;i<m;i++)if(snum==stu[i].num) /**查找出入的學(xué)號(hào)是否在記錄中 */{printf( "findthestudent,show?(y/n)" );scanf("%s",ch);if(strcmp(ch, "y")==0||strcmp(ch, "Y")==0){printf( "number name elective experiment requiredsum\t\n" );printf(FORMAT,DATA); /*將查找出得結(jié)果按指定格式輸出 */break;}}if(i==m)printf( "cannotfindthestudent!\n" ); /*沒有找到要查額信息 */system("pause");}void modify() /*自定義修改函數(shù) */{int i,j,snum,m=0;FILE*fp;if((fp=fopen( "d:\\data.txt" ,"ab+"))==NULL){printf("cannotopen\n");return;}while(!feof(fp))if(fread(&stu[m],LEN,1,fp)==1)m++;if(m==0){printf("norecord!\n");fclose(fp);return;}printf("pleaseinputthenumberofthestudentwhichdoyouwanttomodify!\n");scanf("%d",&snum);for(i=0;i<m;i++)if(snum==stu[i].num)/*檢索記錄中是否有要修改的信息*/break;if(i<m){printf("findthestudent!youcanmodifynow!\n");printf("pleaseinputpercentnm:");printf("\nelective:");scanf("%f",&Ielec);printf("\nexperiment:");更多精品文檔學(xué)習(xí)-----好資料scanf("%f",&Iexpe);printf( "\nrequiredcourse:" );scanf("%f",&Irequ);printf( "name:\n" );scanf( "%s",&stu[i].name);printf( "\nelective:" );scanf( "%lf",&stu[i].elec);printf( "\nexperiment:" );scanf( "%lf",&stu[i].expe);printf( "\nrequiredcourse:" );scanf( "%lf",&stu[i].requ);stu[i].sum=stu[i].elec*Ielec+stu[i].expe*Iexpe+stu[i].requ*Irequ;}else{printf( "cannotfind!" );getch();return ;}if((fp=fopen( "d:\\data.txt" ,"wb"))==NULL){printf( "cannotopen\n" );return ;}for(j=0;j<m;j++)if(fwrite(&stu[j],LEN,1,fp)!=1){printf( "cannotsave!" );getch();}fclose(fp);}void del() /*自定義刪除函數(shù) */{int snum,i,j,m=0;charch[2];FILE*fp;if((fp=fopen( "d:\\data.txt" ,"ab+"))==NULL){printf( "cannotopen\n" );return ;}while(!feof(fp))if(fread(&stu[m],LEN,1,fp)==1)m++;fclose(fp);if(m==0){更多精品文檔學(xué)習(xí)-----好資料printf( "norecord!\n" );return ;}printf( "pleaseinputthenumber:" );scanf("%d",&snum);for(i=0;i<m;i++)if(snum=stu[i].num)break;printf( "findthestudent,delete?(y/n)" );scanf("%s",ch);if(strcmp(ch, "y")==0||strcmp(ch, "Y")==0)for(j=i;j<m;j++)stu[j]=stu[j+1];m--;if((fp=fopen( "d:\\data.txt" ,"wb"))==NULL){printf( "cannotopen\n" );return ;}for(j=0;j<m;j++)if(fwrite(&stu[j],LEN,1,fp)!=1) /*將更改后的記錄重新寫入指定的磁盤文件中*/{printf( "cannotsave!\n" );getch();}fclose(fp);printf( "deletesuccessfully!\n" );}void insert() /*自定義插入函數(shù) */{int i,j,k,snum,m=0;FILE*fp;if((fp=fopen( "d:\\data.txt" ,"ab+"))==NULL){printf( "cannotopen\n" );return ;}while(!feof(fp))if(fread(&stu[m],LEN,1,fp)==1)m++;if(m==0){printf( "norecord!\n" );fclose(fp);return ;}printf( "pleaseinputthepositionwhereyouwanttoinsert!\n" );更多精品文檔學(xué)習(xí)-----好資料scanf("%d",&snum); /*輸入要插入的位置 */for(i=0;i<m;i++)if(snum==stu[i].num)break;for(j=m-1;j>i;j--)stu[j+1]=stu[j]; /*從最后一條記錄開始均向后移一位 */printf( "pleaseinputthenewinformation:\n" );printf( "number:" );scanf( "%d",&stu[i+1].num);for(k=0;k<m;k++)if(stu[k].num==stu[i+1].num&&k!=i+1){printf( "thenumberisexisting,pressanytocontinue!" );getch();fclose(fp);return ;}printf( "pleaseinputpercentum:" );printf( "\nelective:" );scanf("%f",&Felec);printf( "\nexperiment:" );scanf("%f",&Fexpe);printf( "\nrequiredcourse:" );scanf("%f",&Frequ);printf( "name:\n" );scanf( "%s",&stu[i+1].name);printf( "\nelective:" );scanf( "%lf",&stu[i+1].elec);printf( "\nexperiment:" );scanf( "%lf",&stu[i+1].expe);printf( "\nrequiredcourse:" );scanf( "%lf",&stu[i+1].requ);stu[i+1].sum=stu[i+1].elec*Felec+stu[i+1].expe*Fexpe+stu[i+1].requ*Frequ; /*計(jì)算總成績 */if((fp=fopen( "d:\\data.txt" ,"wb"))==NULL){printf( "cannotopen\n" );return ;}for(k=0;k<=m;k++)if(fwrite(&stu[k],LEN,1,fp)!=1) /*將修改后的記錄寫入磁盤中 */{printf( "cannotsave!" );getch();}fclose(fp);}更多精品文檔學(xué)習(xí)-----好資料void sort() /*自定義

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論