這篇文章主要介紹C語(yǔ)言如何實(shí)現(xiàn)班檔案管理系統(tǒng)課程設(shè)計(jì),文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
本文實(shí)例為大家分享了C語(yǔ)言班檔案管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
#include<stdio.h> #include<stdlib.h> #include<string.h> #define N 20 struct student { long num; char name[20]; char sex[10]; int age; char bz[40]; struct student *next; }; int i,j,n,num2,num3,age3,k,m; char name3[20],sex3[20],bz3[20],ch; FILE *fp; int login() //登陸函數(shù) { char key[20]; printf("\t ********************請(qǐng)輸入系統(tǒng)密碼********************\n"); do { scanf("%s",key); if((strcmp("a",key))==0) { printf("\t password correct ,welcome !\n"); return 1; //當(dāng)密碼正確時(shí),返回1,進(jìn)入系統(tǒng) } printf("\t password incorrect,please input again!\n"); }while(key!=1);//當(dāng)返回值不為1時(shí),重新輸入密碼,直到輸入真確為止 system("cls"); } int menu() //菜單 { int c; printf("\t\t**********歡迎進(jìn)入通訊客戶端!************\n\n"); printf("\t\t|—————1.錄入學(xué)生的基本信息—————|\n"); printf("\t\t|----------2.顯示學(xué)生的基本信息----------|\n"); printf("\t\t|----------3.保存學(xué)生的基本信息----------|\n"); printf("\t\t|----------4.刪除學(xué)生的基本信息----------|\n"); printf("\t\t|----------5.修改學(xué)生的基本信息----------|\n"); printf("\t\t|----------6.查詢學(xué)生的基本信息----------|\n"); printf("\t\t|—————7.退出系統(tǒng)——————————|\n"); printf("\t\t請(qǐng)選擇您要進(jìn)行的功能(0~7) "); scanf("%d",&c); return c; } struct student *creat() //錄入信息函數(shù) { struct student *head,*p1,*p2; n=0; p1=p2=(struct student *)malloc(sizeof(struct student)); head=NULL; printf("請(qǐng)輸入學(xué)生信息學(xué)號(hào),姓名,性別,年齡,備注(鍵入學(xué)生學(xué)號(hào)為0時(shí)結(jié)束)\n"); while(1) //為1表真,p2->next不為0; { scanf("%d",&p1->num); if(p1->num==0) //判斷學(xué)生的學(xué)號(hào)是否為0,如果為0則停止輸入數(shù)據(jù); { break; } scanf("%s%s%d%s",p1->name,p1->sex,&p1->age,p1->bz); n=n+1; if(n==1) { head=p1; } else { p2->next=p1; } p2=p1; p1=(struct student *)malloc(sizeof(struct student)); } p2->next=NULL; system("cls"); return(head); } void print(struct student *head) //輸出信息函數(shù) { struct student *p; printf("\t\t這里有 %d 個(gè)學(xué)生的數(shù)據(jù)信息\n",n); p=head; if(head!=NULL) { do { printf("\t\t學(xué)號(hào):%d\t姓名:%s\t性別:%s\t年齡:%d\t備注:%s\n",p->num,p->name,p->sex,p->age,p->bz); p=p->next; }while(p!=NULL); } else { return 0; } printf("\n"); } int save(struct student *p) //保存信息函數(shù) { FILE *fp; if((fp=fopen("keshe.txt","wb"))==NULL) { printf("open file fail\n"); } fp=fopen("stud","wb"); do { fwrite(p,sizeof(struct student),1,fp); p=p->next; }while(p!=NULL); printf("\t\t\t保存成功!\n"); fclose(fp); return 0; } struct student *del(struct student *head) { struct student *p1,*p2; printf("\t\t請(qǐng)輸入要?jiǎng)h除學(xué)生的學(xué)號(hào)\n"); scanf("%d",&num2); p1=head; if(head->num==num2) { head=head->next; free(p1); n--; } else { p2=head; while(p2->num!=num2&&p2->next!=NULL) { p1=p2; p2=p2->next; } if(p2->num==num2) { p1->next=p2->next; n--; } printf("delete:%ld\n",num2); } return (head); } int mod(struct student *head); //修改信息函數(shù) struct student *modify(struct student *head) { if(login()==0) { return 0; } else { struct student *p1; j=0; p1=(struct student *)malloc(sizeof(struct student)); printf("\t\t\t請(qǐng)輸入你要更改的學(xué)號(hào)\n"); scanf("%d",&num2); printf("\t\t\t學(xué)號(hào)\n"); scanf("%d",&num3); printf("\t\t\t姓名\n"); scanf("%s",name3); printf("\t\t\t性別\n"); scanf("%s",sex3); printf("\t\t\t年齡\n"); scanf("%d",&age3); printf("\t\t\t備注\n"); scanf("%s",bz3); p1=head; if(head->num==num2) { head->num=num3; strcpy(head->name,name3); strcpy(head->sex,sex3); head->age=age3; strcpy(head->bz,bz3); j=1; } else { p1=head->next; if(p1!=NULL) { while(p1->num!=num2) { p1=p1->next; } p1->num=num2; strcpy(p1->name,name3); strcpy(p1->sex,sex3); p1->age=age3; strcpy(p1->bz,bz3); j=1; } } if(j==0) { printf("\t\t\t更改失敗\n"); } else { printf("\t\t\t更改成功\n"); } } system("cls"); mod(head); } int mod(struct student *head) { printf("\t\t\t請(qǐng)選擇\n"); printf("\t\t\t1:按學(xué)號(hào)修改學(xué)生信息\n"); printf("\t\t\t2:輸出修改后的學(xué)生信息\n"); printf("\t\t\t3:返回主菜單\n"); scanf("%d",&m); switch(m) { case 1:head=modify(head);break; case 2:print(head);break; case 3:menu();break; default:printf("\t\t\tinput error!\n"); mod(head); } } int find(struct student *head); int find1(struct student *head) //以學(xué)號(hào)方式查找 { struct student *p1; p1=(struct student *)malloc(sizeof(struct student)); printf("\t\t\t請(qǐng)輸入你要查詢的學(xué)生學(xué)號(hào)\n"); scanf("%d",&num2); p1=head; while(p1!=NULL) { if(p1->num==num2) { k=1; printf("\t\t\t學(xué)號(hào):%d\t姓名:%s\t性別:%s\t年齡:%d\t備注:%s\n\n",p1->num,p1->name,p1->sex,p1->age,p1->bz); break; } p1=p1->next; } if(k==0) { printf("\t\t\t沒(méi)有查詢到您要找的學(xué)生信息\n\n"); } else { printf("\t\t\t這就是您要找的學(xué)生信息\n\n"); } find(head); } int find2(struct student *head) //以姓名方式查找 { struct student *p1; p1=(struct student *)malloc(sizeof(struct student)); printf("\t\t\t請(qǐng)輸入您要查詢的學(xué)生姓名\n"); scanf("%s",name3); p1=head; while(p1!=NULL) { if((strcmp(p1->name,name3))==0) { k=1; printf("\t\t\t學(xué)號(hào):%d\t姓名:%s\t性別:%s\t年齡:%d\t備注:%s\n\n",p1->num,p1->name,p1->sex,p1->age,p1->bz); break; } p1=p1->next; } if(k==0) { printf("\t\t\t沒(méi)有找到該學(xué)生信息\n\n"); } else { printf("\t\t\t這就是您要查詢的學(xué)生信息\n\n"); } find(head); } int find3(struct student *head) //以性別方式查找 { struct student *p1; p1=(struct student *)malloc(sizeof(struct student)); printf("\t\t\t請(qǐng)輸入你要查詢的學(xué)生的性別\n"); scanf("%s",sex3); p1=head; while(p1!=NULL) { if((strcmp(p1->sex,sex3))==0) { k=1; printf("\t\t\t學(xué)號(hào):%d\t姓名:%s\t性別:%s\t年齡:%d\t備注:%s\n\n",p1->num,p1->name,p1->sex,p1->age,p1->bz); break; } p1=p1->next; } if(k==0) { printf("\t\t\t沒(méi)有找到該學(xué)生信息\n\n"); } else { printf("\t\t\t這就是您要查詢的學(xué)生的信息\n\n"); } find(head); } int find4(struct student *head) //以年齡方式查找 { struct student *p1; p1=(struct student *)malloc(sizeof(struct student)); printf("\t\t\t請(qǐng)輸入您要查詢的學(xué)生的年齡\n"); scanf("%d",&age3); p1=head; while(p1!=NULL) { if(p1->age==age3) { k=1; printf("\t\t\t學(xué)號(hào):%d\t姓名:%s\t性別:%s\t年齡:%d\t備注:%s\n\n",p1->num,p1->name,p1->sex,p1->age,p1->bz); break; } p1=p1->next; } if(k==0) { printf("\t\t\t沒(méi)有找到該學(xué)生的信息\n\n"); } else { printf("\t\t\t這就是您要找的學(xué)生的信息\n\n"); } find(head); } int find(struct student *head) { printf("\t\t\t請(qǐng)選擇您要查詢學(xué)生信息的方式\n"); printf("\t\t\t1:按學(xué)生學(xué)號(hào)查詢\n"); printf("\t\t\t2:按學(xué)生姓名查詢\n"); printf("\t\t\t3:按學(xué)生性別查詢\n"); printf("\t\t\t4:按學(xué)生年齡查詢\n"); printf("\t\t\t5:返回主菜單\n"); scanf("%d",&m); switch(m) { case 1:find1(head);break; case 2:find2(head);break; case 3:find3(head);break; case 4:find4(head);break; case 5:system("cls");menu();break; default:printf("\t\t\tinput error,please input again\n"); } } int main() //主函數(shù) { struct student *phead; if(login()==0) { return 0; } printf("\n"); while(1) { switch(menu()) { case 1:system("cls");phead=creat();break; case 2:system("cls");print(phead);break; case 3:system("cls");save(phead);break; case 4:system("cls");phead=del(phead);break; case 5:system("cls");mod(phead);break; case 6:system("cls");find(phead);break; case 7:system("cls");printf("\t\t\t歡迎使用,再見(jiàn)!\n");return 0; default:printf("\t\t\t輸入有錯(cuò),請(qǐng)重新輸入\n"); } } }
以上是“C語(yǔ)言如何實(shí)現(xiàn)班檔案管理系統(tǒng)課程設(shè)計(jì)”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司行業(yè)資訊頻道!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站jinyejixie.com,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)頁(yè)題目:C語(yǔ)言如何實(shí)現(xiàn)班檔案管理系統(tǒng)課程設(shè)計(jì)-創(chuàng)新互聯(lián)
鏈接分享:http://jinyejixie.com/article42/digpec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、微信公眾號(hào)、動(dòng)態(tài)網(wǎng)站、虛擬主機(jī)、網(wǎng)頁(yè)設(shè)計(jì)公司、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容