版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>#define N 100struct student int student_id; char student_name19; char password13; char sign255;typedef structint numkc; char num10; char name20; int score; int scoreps; int scorejm; char kecheng; int xuefen
2、; int scoresy; int numss; char sex; int phone;Student;Student stu80;int length_student_name(char *p) int l; l=strlen(p); if(l>18|l<1) return 0; else return l;int valid_student_name(char *p) int i=0; int len = strlen(p); if(*p >= 'a' && *p <= 'z') | (*p >= '
3、A' && *p <='Z') for(i = 0; i < len; i+) if(!(pi = '_' | (pi >= 'a' && pi <= 'z') | (pi >= 'A' && pi <='Z') |(pi >='0' && pi <= '9') return 0; return 1; else return 0;int is_stu
4、dentname_valid(char *p) if(*p >= 'a' && *p <= 'z') | (*p >= 'A' && *p <='Z') p+; while(*p) if(!(isalpha(*p) | *p = '_' | isdigit(*p) return 0; p+; return 1; else return 0; int length_password(char *p) int len; len = strlen(p); if(le
5、n<6|len>12) return 0; else return len;int is_password_valid(char *p) int i=0; for(;*p != '0' p+) if(!( (*p >= 'a' && *p <= 'z') | (*p >= 'A' && *p <='Z') |(*p >='0' && *p <= '9') return 0; return
6、1;int two_password_valid(char *p1,char*p2) if(strcmp(p1,p2)=0) return 1; else return 0;int student_register(struct student *ptr_student,int size) char password13; char repassword13; if(size=N) puts("zhucerenshu yi man!"); return 0; printf("qing shu ru zhu ce xing ming:"); fflush(
7、stdin); gets(ptr_studentsize.student_name); if(!(length_student_name(ptr_studentsize.student_name)&&valid_student_name(ptr_studentsize.student_name) printf("ni shu ru de wu xiao !"); return 0; printf("qing shu ru zhu ce mi ma:"); fflush(stdin); gets(password); printf(&quo
8、t;qing zai ci shu ru zhu ce mi ma:"); fflush(stdin); gets(repassword); if(!two_password_valid(password,repassword) printf("nliang ci shu rude mi ma bu yi zhi !"); return 0; else strcpy(ptr_studentsize.password,password); if(!(length_password(ptr_studentsize.password)&&is_passw
9、ord_valid(ptr_studentsize.password) printf("mi ma wu xiao!"); return 0; fflush(stdin); gets(ptr_studentsize.sign); printf("ni de bian hao wei :%d,zhe jiang shi ni de denglu zhang hao .",ptr_studentsize.student_id=10000+size); return 1;int is_my_student(struct student *p,int size)
10、 int i; int zhanghu; char mima15; printf("qing shu ru ni de zhanghao : "); scanf("%d",&zhanghu); fflush(stdin); printf("qing shu ru ni de mi ma : "); gets(mima); for(i=0;i<size;i+) if(zhanghu = pi.student_id)&&(strcmp(mima,pi.password)=0) return i + 1; re
11、turn 0;int menu_select() char c; do system("cls"); printf("tt *Students' Grade Management System*n"); printf("tt| 1. Input Records |n"); printf("tt| 2. Display All Records |n"); printf("tt| 3. Sort |n"); printf("tt| 4. Insert a Record |n&quo
12、t;); printf("tt| 5. Delete a Record |n"); printf("tt| 6. chaxun_name |n"); printf("tt| 7. chaxun_number |n"); printf("tt| 8. chaxun_numberss |n"); printf("tt| 9. chaxun_num |n"); printf("tt| 10. Statistic |n"); printf("tt| 11. Add Reco
13、rds from a Text File |n"); printf("tt| 12. Write to a Text file |n"); printf("tt| 0. Quit |n"); printf("tt*n"); printf("tttGive your Choice(0-12):"); scanf("%d",&c); while(c<0|c>12); return(c); int Input(Student stud,int n)int i=0;char
14、 sign,x10;while(sign!='n'&&sign!='N') printf("tttstudent's num:"); scanf("ttt%s",studn+i.num);printf("tttkechengbianhao:");scanf("ttt%s",studn+i.numkc); printf("tttstudent's name:"); scanf("ttt%s",studn+i.nam
15、e); printf("tttstudent's scoreps:"); scanf("ttt%d",&studn+i.scoreps);printf("tttkechengmingcheng:");scanf("ttt%s",&studn+i.kecheng);printf("tttstudent's scorejm:");scanf("ttt%d",&studn+i.scorejm);printf("tttstudent&
16、#39;s xuefen");scanf("ttt%d",&studn+i.xuefen);printf("tttstudent's scoresy:");scanf("ttt%d",&studn+i.scoresy);printf("tttstudent's numss:");scanf("ttt%s",studn+i.numss);printf("tttstudent's sex:");scanf("ttt%s&
17、quot;,&studn+i.sex);printf("tttstudent's phone:");scanf("ttt%d",&studn+i.phone);printf("tttstudent's xuefen:");scanf("ttt%d",&studn+i.xuefen);gets(x);printf("tttany more records?(Y/N)"); scanf("ttt%c",&sign);i+;retur
18、n(n+i);void qiuzhi(Student stud,int i)float zonghe20,xuefensd20;if (studi.scoresy=-1)zonghei=studi.scoreps*0.3+studi.scorejm*0.7;printf("zonghei is %f",zonghei);elsezonghei=studi.scoreps*0.15+studi.scoresy*0.15+studi.scorejm*0.7;printf("zonghei is %f",zonghei);if (zonghei>=90&
19、amp;&zonghei<=100)xuefensdi=studi.xuefen*1;printf("xuefensdi is %f",xuefensdi);if (zonghei>=80&&zonghei<90)xuefensdi=studi.xuefen*0.8;printf("xuefensdi is %f",xuefensdi);if (zonghei>=70&&zonghei<80)xuefensdi=studi.xuefen*0.75;printf("xuefen
20、sdi is %f",xuefensdi);if (zonghei>=60&&zonghei<70)xuefensdi=studi.xuefen*0.6;printf("%f",xuefensdi);elsexuefensdi=0;printf("xuefensdi is %f",xuefensdi);void Display(Student stud,int n)int i;printf("ttt-n");printf("tttnumber name scoren");pri
21、ntf("tttxuefensd zonghe numssn");printf("ttt-n");for(i=1;i<n+1;i+)printf("ttt%-16s%-15s%dn",studi-1.num,,studi-1.score);if(i>1&&i%10=0) printf("ttt-n"); printf("ttt"); system("pause"); printf("ttt-n"); pr
22、intf("ttt");system("pause");void Sort_by_num(Student stud,int n) int i,j,*p,*q,s; char t10; for(i=0;i<n-1;i+) for(j=0;j<n-1-i;j+) if(strcmp(studj.num,studj+1.num)>0) strcpy(t,studj+1.num); strcpy(studj+1.num,studj.num); strcpy(studj.num,t); strcpy(t,studj+1.name); strcpy
23、(studj+1.name,); strcpy(,t); p=&studj+1.score; q=&studj.score; s=*p; *p=*q; *q=s; int Insert_a_record(Student stud,int n)char x10; printf("tttstudent's num:"); scanf("ttt%s",studn.num); printf("tttstudent's name:"); scanf("ttt%s&
24、quot;,); printf("tttstudent's score:"); scanf("ttt%d",&studn.score); gets(x); n+; Sort_by_num(stud,n); printf("tttInsert Successed!n"); return(n);int Delete_a_record(Student stud,int n) char s20; int i=0,j; printf("ttttell me his(her) name:")
25、; scanf("%s",s); while(strcmp(,s)!=0&&i<n) i+; if(i=n) printf("tttnot find!n"); return(n); for(j=i;j<n-1;j+) strcpy(studj.num,studj+1.num); strcpy(,studj+1.name); studj.score=studj+1.score; printf("tttDelete Successed!n"); return(n-1);v
26、oid chaxun_name(Student stud,int n)/*用姓名查詢基本信息*/ char s20; int i=0; printf("tttinput his(her) name:"); scanf("ttt%s",s); while(strcmp(,s)!=0&&i<n) i+; if(i=n) printf("tttnot find!n"); return; printf("ttthis(her) number:%sn",studi.num); pri
27、ntf("ttthis(her) sex:%dn",studi.sex); printf("ttthis(her) numss:%dn",studi.numss); printf("ttthis(her) phone:%dn",studi.phone);void chaxun_number(Student stud,int n)/*用學(xué)號查詢基本信息*/ char num10; int i=0; printf("tttinput his(her) number:"); scanf("ttt%d"
28、,num); while(strcmp(studi.num,num)!=0&&i<n) i+; if(i=n) printf("tttnot find!n"); return; printf("ttthis(her) name:%dn",); printf("ttthis(her) sex:%dn",studi.sex); printf("ttthis(her) numss:%dn",studi.numss); printf("ttthis(her) phone:
29、%dn",studi.phone);void chaxun_numss(Student stud,int n)/*用宿舍號碼查詢學(xué)生基本信息*/ char numss10; int i=0; printf("tttinput his(her) dormitory number:"); scanf("ttt%d",numss); while(strcmp(studi.numss,numss)!=0&&i<n) i+; if(i=n) printf("tttnot find!n"); return; pri
30、ntf("ttthis(her) name:%dn",); printf("ttthis(her) sex:%dn",studi.sex); printf("ttthis(her) num:%dn",studi.num); printf("ttthis(her) phone:%dn",studi.phone);void chaxun_num(Student stud,int n)/*用學(xué)號查詢學(xué)生課程信息*/ char numss20; int i=0; printf("tttinpu
31、t his(her) number:"); scanf("ttt%d",numss); while(strcmp(studi.numss,numss)!=0&&i<n) i+; if(i=n) printf("tttnot find!n"); return; printf("ttthis(her) num:%dn",studi.num); printf("ttthis(her) numkc:%dn",studi.numkc); printf("ttthis(her) kec
32、heng:%sn",studi.kecheng); printf("ttthis(her) xuefen:%dn",studi.xuefen); printf("ttthis(her) scoreps:%dn",studi.scoreps); printf("ttthis(her) scoresy:%dn",studi.scoresy); printf("ttthis(her) scorejm:%dn",studi.scorejm);void Statistic(Student stud,int n)in
33、t i,j=0,k=0,sum=0; float aver; for(i=0;i<n;i+) sum+=studi.score; if(studj.score>studi.score) j=i; if(studk.score<studi.score) k=i; aver=1.0*sum/n; printf("tttthere are %d records.n",n); printf("tttthe hignest score:n"); printf("tttnumber:%s name:%s score:%dn",s
34、tudj.num,,studj.score); printf("tttthe lowest score:n"); printf("tttnumber:%s name:%s score:%dn",studk.num,,studk.score); printf("tttthe average score is %5.2fn",aver);int AddfromText(Student stud,int n) int i=0,num; FILE *fp; char filename20; printf
35、("tttInput the filename:"); scanf("ttt%s",filename); if(fp=fopen(filename,"rb")=NULL) printf("tttcann't open the filen"); printf("ttt"); system("pause"); return(n); fscanf(fp,"%d",&num); while(i<num) fscanf(fp,"%s%
36、s%d",studn+i.num,studn+,&studn+i.score); i+; n+=num; fclose(fp); printf("tttSuccessed!n"); printf("ttt"); system("pause"); return(n);void WritetoText(Student stud,int n)int i=0;FILE *fp;char filename20; printf("tttWrite Records to a Text Filen")
37、; printf("tttInput the filename:"); scanf("ttt%s",filename); if(fp=fopen(filename,"w")=NULL) printf("tttcann't open the filen"); system("pause"); return; fprintf(fp,"%dn",n); while(i<n) fprintf(fp,"%-16s%-15s%dn",studi.num,
38、,studi.score); i+; fclose(fp); printf("Successed!n");void guanli()int n=0; for(;) switch(menu_select()case 1: printf("tttInput Recordsn"); n=Input(stu,n); break; case 2: printf("tttDisplay All Recordsn"); Display(stu,n); break; case 3: printf("tttSortn&qu
39、ot;); Sort_by_num(stu,n); printf("tttSort Suceessed!n"); printf("ttt"); system("pause"); break; case 4: printf("tttInsert a Recordn"); n=Insert_a_record(stu,n); printf("ttt"); system("pause"); break; case 5: printf("tttDelete a Recordn
40、"); n=Delete_a_record(stu,n); printf("ttt"); system("pause"); break; case 6: printf("tttchaxun_namen"); chaxun_name(stu,n); printf("ttt"); system("pause"); break; case 7: printf("tttchaxun_numbern"); chaxun_number(stu,n); printf("
41、ttt"); system("pause"); break; case 8: printf("tttchaxun_numssn"); chaxun_numss(stu,n); printf("ttt"); system("pause"); break; case 9: printf("tttchaxun_numn"); chaxun_num(stu,n); printf("ttt"); system("pause"); break; case 1
42、0: printf("tttStatisticn"); Statistic(stu,n); printf("ttt"); system("pause"); break; case 11: printf("tttAddfromTextn"); AddfromText(stu,n); printf("ttt"); system("pause"); break; case 12: printf("tttWritetoTextn"); WritetoText(stu,n); printf("ttt"); system("pause"); break;void display_student(struct student u) printf("nni de zhang hao shi :%d",u.student_id); printf("nni de zhu ce xing ming shi :%s",u.student_name);getch();guanli(); printf("npress anykey
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 電力系統(tǒng)能源管理合同
- 家庭裝修施工安全責(zé)任的協(xié)議書2025年
- 機床夾具支架課程設(shè)計
- 外賣服務(wù)合同糾紛處理典型案例分析3篇
- 保密協(xié)議的履行期限3篇
- 劇院車輛停放管理合同3篇
- 典當(dāng)借款合同范本3篇
- 機械課程設(shè)計講座
- 光伏項目協(xié)議范本3篇
- 新建鉗工工具項目實施方案
- 醫(yī)藥公司中藥采購年終工作總結(jié)(8篇)
- 境外投資設(shè)備合同模板
- 滬科版數(shù)學(xué)八年級上冊期末考試試卷含答案
- 2024年新(網(wǎng)絡(luò)攻防、網(wǎng)絡(luò)信息安全管理)知識考試題庫與答案
- 江蘇省昆山市、太倉、常熟、張家港市2023-2024學(xué)年八年級上學(xué)期期末陽光測評語文試卷
- 2024年全國職業(yè)院校技能大賽中職組(法律實務(wù)賽項)考試題庫-下(多選、判斷題)
- 國際結(jié)算第五版劉衛(wèi)紅課后參考答案
- SH∕T 3097-2017 石油化工靜電接地設(shè)計規(guī)范
- 傳統(tǒng)文化與生態(tài)文明建設(shè)智慧樹知到期末考試答案章節(jié)答案2024年云南大學(xué)
- 敦煌學(xué)智慧樹知到期末考試答案章節(jié)答案2024年西北師范大學(xué)
- 數(shù)字孿生在酒廠管理中的運用
評論
0/150
提交評論