版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1.雜志訂閱管理軟件#include"stdio.h"#include"stdlib.h"#include"string.h"structmagzine(charname[10];charsex[2];charaddr[14];intphone_num;intprice;intnum;chardate[10];}kehu[10];voidadd();voidseek();voidtotal();voidmenu();voidmain(){FILE*fp;fp=fopen("信息.txt","r");menu();fclose(fp);}voidmenu()intn;printf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\t*\n");\n");\n");\n");\n");*\n");printf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\tprintf("\t\t*\n");\n");\n");\n");\n");*\n");.增加新用戶.查詢并刪除到期信息.統(tǒng)計(jì)總訂閱數(shù).退出,*******************************************:printf("選擇您的操作(l-4):\n\n");scanf(”%d”,&n);getchar();while(l)(switch(n)(default:printf(“無此功能、n");break;casel:add();break;case2:seek();break;case3:total();break;case4:exit(0);break;}}}voidadd(){FILE*fp;inti,m;fp二fopen(“信息?txゼ貿(mào)wb“);printf("輸入幾組ヘバ);scanf(”%d”,&m);for(i=0;i<m;i++)(printf("姓名性別地址電話號(hào)碼單價(jià)數(shù)量日期、バ);scanf("%s%s%s%d%d%d%s"/kehu[i].name/kehu[i].sex/kehu[i].addr/&kehu[i].phone_num/&kehu[i].price,&kehu[i].num,kehu[i].date);}fclose(fp);menu();}voidseek()(FILE*fp;inti,m,sum=O;chartime[14],choose[2];fp二fopen("信息.txt”Jr“);for(m=0;!feof(fp);m++)fread(&kehu[m],sizeof(structmagzine),l,fp);fclose(fp);printf(”請輸入日期:");scanf(H%s",time);if((fp二fopen("信息.txt","w"))==NULL)printf("對不起,文件打不開、n\n");exit(O);}for(i=0;i<m;i++)(if(strcmp(kehu[i].dateztime)<O)(sum++;printf("%s%s%s%d%d%d%s\n\n”,kehu[i].namezkehu[i].sexzkehu[i].addrzkehu[i].phone_numzkehu[i].price,kehu[i].numzkehu[i].date);printf("\n\n此用戶過期”);printf("\n\n是否刪除('Y‘或'N'):");scanf("%sHzchoose);if(strcmp(choosez,'Y")==011strcmp(choosez"y")==0)continue;|fwrite(&kehu[i]zsizeof(structmagzine),l,fp);}fclose(fp);if(sum==0){printf("對不起,找不到您要的信息!、n\n");}menu();}voidtotal()(FILE*fp;inti,sum=O;fp=fopen("信息.txt",T);for(i=0;i<10;i++){fread(&kehu[i],sizeof(structmagzine),l,fp);sum+=*&kehu[i].num;)printf("總數(shù)=\t%d\n\n",sum);menu();2.購物卡管理系統(tǒng)//?定義信用卡結(jié)構(gòu)體?/#include<stdio.h>#include<ctype.h>#include<stdlib.h>#include<conio.h>#include<string.h>#defineM1000voidmenu();voidmade();voidadd();voidlife();voidenter();voidbrowse();voidhuo(intk);voidhedui(intk);voidmenul(intk);voidfetch(intk);voidchange(intk);voiddeposit(intk);voidstat_one(intk);voidprint__one(intj);intsearch(charh[20]);intn=0;structcredicard/?調(diào)用字符函數(shù)?//?通用輸入輸出庫ッintnumber;charname[20];charID[20];charword[8];intflag;floataccount;intintegal;}card[M];voidmenu()(intv,wl;doprintf("\n\n\n\nH);printf("ヽt\t<THEMENU>\n");printf("\t\t|I ⑴制卡操作 ||'バ);printf("\t\t|I 1|\n");printf("\t\t||(2)帳號(hào)激活ll\n");printf("\t\t|| — ||\n");printf("\t\t||(3)帳戶登陸ll\n");printf("\t\t|| — ||\n");printf("\t\t||(4)報(bào)表操作ll\n");printf("\t\t|| — ||\n");printf("\t\t||(5)退出ll\n");printf("\t\t|| ll\n");printf("\n\n\t\t請選擇操作(1-5):<>\b\b");scanf("%d",&v);if(v<l||v>5)printf("\n\n\t\t**********入有誤i************h).wl=l;getchar();)elsewl=O;}while(wl==l);switch(v)(casel:made();break;/?制作?/case2:life();break; /?激活ッcase3:enter();break; /?登陸?/case4:browse();break;/?報(bào)表*/case5:exit(0); /?退出?/)}voidmain(){printf("\n\n\n\n\n\n\n\n\n");p「jntf("ヽt\t********************* 理一系***********************printf(-\n\n\n\t\t按任意鍵進(jìn)入 ");getchar();menu();}voidmade() /?制卡操作?/inti;charh[20];doprintf(”ヽn\n\t請輸入要申請的號(hào)碼:<\t\t\t>\b\b\b\b\b\b\b”);scanf("%s",h);if(strlen(h)!=6)printf("\n\n\n\t\t**************輸入有誤,請重新輸入**************continue;}for(i=0;i<n;i++)if(strcmp(card[i].ID/h)==O)printf(,ヽn\n\t\t**********該號(hào)碼已經(jīng)存在,請重新輸入**********、n\n");break;)while({(strlen(h))!=6)||strcmp(card[i].ID/h)==O);card[n].number=n;strcpy(card[n].name;****");strcpy(card[n].IDzh);strcpy(card[n].word/'000000");card[n].flag=O;card[n].account=0.00;card[n].integal=O;printf("ヽn\n\n\t\t*******************?制]!**********************、ハ、バ),print_one(n);n++;add();menu();}voidprint_one(intj) /?顯示消息?/{TOC\o"1-5"\h\zprintf("\n|--| 1 1--| 1 1");printf("\n|NO.| name | ID |flag|account|integal1");printf("\n|--| 1 1--| 1 1");printf("\n|%4d|%20s|%20s|%4d|%10.2f|%10d|",card[j],number,card[j].name,card[j].ID,card[j].flag,card[j].account,card[j].integal);printf(H\n|--| 1 1—| 1 1");}voidadd() /?存款?/(inti;FILE*fp;if((fp=fopen("score.txt","wb"))==NULL)printf("\t\tCannotopenthefile\n");
return;}for(i=0;i<n;i++)if(fwrite(&card[i],sizeof(structcredicard^ljp)!=1)(printf("\t\tFilewriteerror\nH);return;)fclose(fp);printf("\n\n\n\t\t************成功保存リ〔************").}voidlife() /?登陸ッ(intk=-l;charh[20];if(n==0)printf("\n\n\t\t************************************printf("\n\n\t\t************************************elseprintf(“ヽn\n\t請輸入購物卡號(hào)碼:<\t\t\tハb\b\b\b\b\b\b“);scanf("%s",h);k=search(h);if(k==-l)p匕ntf("ヽn\n\t\t\t***************** ド***************if(card[k].flag==l)printf("\n\n\t\t卜二printf("\n\n\t\t卜二I活*I****************elsehuo(k);}menu();}intsearch(charh[20])inti,k=-l;for(i=0;i<n;i++)if(strcmp(card[i].ID,h)==O)k=i;return(k);|/?/?激活操作?/charm[20],p[8];intx,w2;doprintf("\n\n\t\t是否激活該卡?⑴是prinザ、n\t\t請選擇卡號(hào):<>\b\b“);scanf(“%dツ&x);if(x<l||x>2){w2=l;getchar();}elsew2=0;(2)否\n");while(w2==l);if(x==l)printf("\n\n\t\t請輸入姓名:<\t\t\t>\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");scanf("%s",m);strcpy(card[k].namezm);printf(“\n\n\t\t請輸入六位數(shù)密碼:<scanf(“%s,p);strcpy(card[k].wordzp);card[k].flag=l;printf("\n\n\n\t\t*******************功[**********************、ハバ).>\b\b\b\b\b\b\b");print_one(k);add。;})voidenter()/?進(jìn)入?/intk=-l;charh[20];if(n==0)printf("\n\n\t\t****************1^先制卡*********************、バ),elseprintf(“\n\n\t請輸入購物卡號(hào)碼:ハb\b\b\b\b\b\b“);scanf(”%s,h);k=search(h);if(k==-l)p「jntf("ヽn\n\t\t\t*****************4^?帀馬,不^^在z產(chǎn)***************\n"),elseif(card[k].flag=O)printf(”\n\n\t\t************該卡還未激活,請先激活!************、バ);elsehedui(k);}menu();}voidhedui(intk) /?驗(yàn)證核對?/(intc=0,w3=0;charp[8];do{printf("\n\n\t\t*******請輸入密碼:< >\b\b\b\b\b\b\b");scanf("%s",p);if(strcmp(card[k].word,p)!=0){printf("ヽn\n\t\t********密碼不正確,請帀新輸入[**********\n");C++;continue;)else{printf("\n\n\t\t**********密碼正確!***********\n"),w3=l;menul(k);)}while(w3==0&&c<3);}voidmenul(intk) /?顯示*/(intv,w4;doprintf("\n\n\n");printf("\t\t< THEMENU1 >\n");printf("\t\t||(1)查詢ll\n");printf("\t\t|| ||\n");printf("\t\t||(2)存款ll\n");printf("\t\t|| ||\n");printf("\t\t||(3)消費(fèi)ll\n");printf("\t\t|| ||\n");printf("\t\t||(4)修改密碼ll\n");printf("\t\t|| 1l\nレprintf("\t\t||⑸返回主菜單ll\n");printf("\t\t|| ll\n");
printf("\n\n\t\tChoiceyournumber。ー5):<>\b\b");scanf(”%d,&v);if(v<l||v>5){w4=l;getchar();}elsew4ニ〇;}while(w4==l);switch(v)(casel:stat_one(k);break;case2:deposit(k);break;case3:fetch(k);break;case4:change(k);break;case5:menu();)}voidstat_one(intk)printf("\n\n\t\t*************操作成功け**************”);printf("\n\n\t\t*************操作成功け**************”);print_one(k);menul(k);}voiddeposit(intk)floata=0.00;printf(”ヽn\n\t\t請輸入存款金額:<\t\t>\b\b\b\b\b\b\b\b\b\b\b");scanf(”%f”,&a);card[k].account+=a;printf(ヽn\nゝ母**********存款成功!***********"print_one(k);add。;menul(k);)voidfetch(intk) /?消費(fèi)?/(floatb=0.00;printい請輸入消費(fèi)金額:<\t\t八b\b\b\b\b\b\b\b\b\b\b“);scanf("%fu/&b);if(b>card[k].account)printf(,f\n\n\t\t**********額不足1*************??j.elsecard[k].account-=b;card[k].integal=b;printf("\n\n\t\t**********W謝惠顧|***********");print_one(k);add();)menul(k);)voidchange(intk) /?修改密碼リ{chara[8]zb[8];printf(”ヽn\n\t\t請輸入新六位數(shù)密碼:v >\b\b\b\b\b\b\b");scanf(“%s”,a);printf(”ヽn\t\t請?jiān)俅屋斎胄铝粩?shù)密碼:< >\b\b\b\b\b\b\b");scanf(M%sM,b);if(strcmp(azb)==O)(printf(H\n\n\t\t**********密碼修改成功!*************")'add();}elseprintf(H\n\n\t\t兩次密碼輸入不一一致,密碼修改失敗門;menul(k);}voidbrowse(){inti;if(n==O)printf("\n\n\t、ビ********?無記錄,請先制卡!***********,);elseprintf("ヽn\n\t\t*************扌第作^ノ或ワJ!**************、バ)?TOC\o"1-5"\h\zprintf("\n|--| 1 1--| 1 ド);printf("\n|NO.|姓名 |卡號(hào) (flag|account|integalprintf("\n|--| 1 1--| 1 1");for(i=0;i<n;i++)printf("\n|%4d|%20s|%20s|%4d|%10.2f|%10dcard[i].number,card[i].name,card[ij.ID,card[i].flag,card[i].account,card[i].integal);printf("\n|--| 1 1—| 1 1");}menu();.C語言課程設(shè)計(jì)ー擔(dān)挑游戲include"stdio.h"voidinit_qipan();voidplayer_move();voidcomputer_move();voiddisp();charcheck();intmain()(chardone;done=,init_qipan();do{disp();player_move();done=check();if(done!=**)break;computer_move();done=check();)while(done=='');if(done==,X')printfC'Youwon!\n");elseprintf(”Youlost!、バ);dispO;getcharf);return0;}charqipan[3][3];voidinit_qipan()(intij;for(i=0;i<3;i++)for(j=0;j<3;j++)qipan[i][j]='}voidplayer_move()(intx,y;printfC'lfsyourturn:");scanf("%d%*c%d",&x,&y);x-;y-;if(qipan[x][y]l="){printf("Error,tryagain.\n");}elseqipan[x][y]='X';voidcomputer_move()(inti,j;for(i=0;i<3;i++)(for(j=0;j<3;j++)if(qipan[i][j]=='')break;if(qipan[i][j]=='')break;}qipan。皿='0';}voiddisp(){intt;for(t=0;t<3;t++)(printf("%cI%cI%c",qipan[t][O],qipan[t][l],qipan[t][2]);if(t!=2)printf("\n-|-|-\n");|printf("\n");charcheck()inti;for(i=0;i<3;i++)if(qipan[i][O]==qipan[i][l]&&qipan[i][O]==qipan[i][2])returnqipan[i][O];for(i=0;i<3;i++)if(qipan[0][i]==qipan[l][i]&&qipan[0][i]==qipan[2][i])returnqipan[O][i];for(i=0;i<3;i++)if(qipan[O][O]==qipan[l][l]&&qipan[O][O]==qipan[2][2])returnqipan[O][O];for(i=0;i<3;i++)if(qipan[0][2]==qipan[l][l]&&qipan[l][l]==qipan[2][0])returnqipan[O][2];return'|.通訊管理#include<stdio.h>#include<stdlib.h>#include<string.h>#include<conio.h>structrecord(charname[20];〃姓名charphone[12]; 〃電話charadress[50]; 〃工作單位chare_mail[20]; 〃電子郵件。}student[100];〃假設(shè)最大數(shù)為100.〃定義全局變量num,表示已經(jīng)輸入的人數(shù)。intnum; 〃這里使用數(shù)組解決通訊錄的問題intmenu_select()(chars[80];inta;/?定義整形變量?/system("cls");printf("\t\t***********歡迎進(jìn)入通訊管理界面********\n\n");
printf("\t\t\tO.printf("\t\t\tl.printf("\t\t\t2.printf("\t\t\t3.printf("\t\t\t4.printf("\t\t\t5.printf("\t\t\t6.輸入記錄'n");printf("\t\t\tO.printf("\t\t\tl.printf("\t\t\t2.printf("\t\t\t3.printf("\t\t\t4.printf("\t\t\t5.printf("\t\t\t6.顯示記錄'n");按姓名查找\n");按電話號(hào)碼查找'n");插入記錄\n");按姓名排序、バ);刪除記錄'バ);printf("\t\t\t7.Quit\n");printf("\t\t***********************************************\n\n")■do{printf("Enteryouchoice(〇?7):");scanf("%s",s);a=atoi(s);}while(a<011a>7);returna;intadduser(){FILE*fp;printf(Hhowmanypeople?[]\b\b");intn;n=getchar();scanf("%d"/&n);inti;for(i=l;i<n+l;i++){fp=fopen("d:\\al.dat'7,wH);printf(H\t\t\t?*****????****?*請輸入用戶停息??**************\pH),printf("\t\t\t輸入姓名:、バ);scanf("%s",student。].name);printf("\t\t\t輸入電話號(hào)碼ヘバ);scanf("%s”,student。].phone);printf("\t\t\t輸入工作單位:'n“);scanf("%s”,student。].adress);printf("\t\t\t輸入e-mail:\n");scanf("%s”,student。].e_mail);if(fwrite(&student[i],sizeof(structrecord),ljp)!=l)printf("failed\n");elseprintf(Hsuccessful\n");fclose(fp);}num=n+num;printf("'t't't是否繼續(xù)添加?(Y/N):'n");if(getch()=='y'11getch()=='Y')adduser();return(O);}intadduser()
{FILE*fp;printf("howmanypeople?[]\b\b");intn;n=getchar();scanf("%d"z&n);inti;for(i=l;i<n+l;i++){fp=fopen("d:\\al.daビJw");printf(n\t\t\t****************請輸入用戶停息****************、バ).printf("\t\t\t輸入姓名:'n“);scanf("%s"zstudent[i].name);printf("\t\t\t輸入電話號(hào)碼:'n“);scanf("%s"zstudent[i].phone);printf("\t\t\t輸入工作單位:'n");scanf("%s"zstudent[i].adress);printf("\t\t\t輸入e-mail:\n");scanf("%s"zstudent[i].e_mail);if(fwrite(&student[i]zsizeof(structrecord)zlzfp)!=l)printf("failed\n");elseprintf("successful\n");fclose(fp);}num=n+num;printf("\t't\t是否繼續(xù)添加?(Y/N):'n“);if(getch()=='y'11getch()==*Y')adduser();return(O);intsearchbyname()intmark=0;inti;printf("\t\t\t***************** 夕弋*******************、バ)?charname[20];printf(“\t\t\t請輸入姓名:'n“);scanf("%s"zname);for(i=0;i<num;i++)if(strcmp(student[i].name/name)==O)printf("\t\t\t*************以下是您查找的用戶信息***********\nH);printf(“\t\t\t姓名:printf(“\t\t\t姓名:printf("\t\t\t電話:printf("\t\t\t地址:printf("\t\t\te-mail:%s"/student[i].name);%s”,student。].phone);%s"/student[i].adress);%s",student[i].e_mail);printf("\t\t\t***********************************************mark++;printf("\t\t\t是否繼續(xù)查找相同名字的用戶信息:(y/n)\n");if(getch()==V11getch()=='Y')(continue;)elsereturn(O);)elseprintf("\t\t\t按任意鍵返回主菜単");getch();return(O);))|if(mark==0){printf("\t\t\t沒有相同姓名的用戶紀(jì)錄'n");printf("\t\t\t按任意鍵返回主菜單任");getch();return(O);return0;}intsearchbyphone()intmark=0;inti;printf("\t\t\t****************** 電i舌^^^^******************、バ)?charphone[10];printf("ヽt\t\t請輸入電話號(hào)碼:\n”);scanf("%s,',phone);for(i=0;i<num;i++)if(strcmp(student[i].phone,phone)==0)printf("\t\t\t**************以下是您查找的用戶信息**********\n");printf("\t\t\t姓名:%s",student。].name);printf("\t\t\t電話:%s",student[i].phone);printf("\t\t\t工作單位:%s",student。].adress);printf("\t\t\te-mail:%s"/student[i].e_mail);prjntf("\t\t\t***********************************************printf("\t\t\t按任意鍵返回主菜單、n");mark++;getch();return(O);})if(mark==0){printf("\t\t\t沒有改用戶的信息、バ);printf("\t\t\t按任意鍵返回主菜單'バ);getch();return(O);}return(O);}voiddeletebyphone(){inti,j;intdeletemark=O;charphone[20];printf("\t\t\t請輸入要?jiǎng)h除用戶電話號(hào)碼:\n");scanf(”%s”,phone);if(num==0){printf("\t\t\t對不起,文件中無任何紀(jì)錄'n");printf("\t\t\t按任意鍵返回主菜單、バ);getch();return;)for(i=0;i<num;i++){if(strcmp(student[i].phonezphone)==0)(printf("\t\t\t以下是您要?jiǎng)h除的用戶紀(jì)錄:\n”);printf("\t\t\t姓名:%s”,student。].name);printf("\t\t\t電話:%s"/student[i].phone);printf(H\t\t\t工作單位:%s"zstudent[i].adress);printf("\t\t\te-mail:%s"/student[i].e_mail);printf("\t\t\t是否刪除?(y/n)”);if(getch()==*y'11getch()=='Y')(for(j=i;j<num-l;j++)student[j]=student[j+l];num-;deletemark++;printf("\t\t\t刪除成功");printf(”\t\t\t是否繼續(xù)刪除?(y/n)”);if(getch()=='y'11getch()=='Y')deletebyphone();return;}elsereturn;)continue;)if(deletemark==O){printf("\t\t\t沒有該用戶的紀(jì)錄ケprintf("\t\t\t是否繼續(xù)刪除?(y/n)");if(getch()=="y'11getch()=='Y')deletebyphone();return;}return;}voiddeletebyname()(inta=0;intfindmark=O;?ntj;intdeletemark=O;inti;charname[20];printf(”\t\t\t請輸入要?jiǎng)h除用戶姓名:'n“);scanf(”%s,name);for(i=a;i<num;i++)(if(strcmp(student[i].namezname)==O){printf("\t\t\t以下是您要?jiǎng)h除的用戶紀(jì)錄:ッ;findmark++;printf("\t\t\t");printf("\t\t\t姓名:%s",student。].name);printf("\t\t\t電話:%s",student[i].phone);printf("\t\t\t地址:%s",student。].adress);printf("\t\t\te-mail:%s”,student。].e_mail);printf("\t\t\t printf(n\t\t\t是否刪除?(y/n)”);if(getch()=='y'11getch()==Y){for(j=i;j<num-l;j++)student[j]=student[j+l];num-;deletemark++;printf("\t\t\t刪除成功");if((i+l)<num)(printf("\t\t\t是否繼續(xù)刪除相同姓名的用戶信息?(y/n)");if(getch()==,y'){a=i;continue;)}printf("\t\t\t是否繼續(xù)刪除?(y/n)");if(getch()=='y')deletebyname();return;}if((i+l)<num)(printf("\t\t\t是否繼續(xù)刪除相同姓名的用戶信息?(y/n)");if(getch()=='y'11getch()=='Y')(a=i;continue;})}elsecontinue;}if((deletemark==O)&&(findmark==O))(printf("\t\t\t沒有該用戶的紀(jì)錄printf(“ヽt\t\t是否繼續(xù)刪除?(y/n門;if(getch()=='y'11getch()=="Y')deletebyphone();return;elseif(findmark!=O){printf("\t\t\t沒有重名信息");printf("\t\t\t沒有該用戶的紀(jì)錄ッ;printf("\t\t\t是否繼續(xù)刪除?(y/n)");if(getch()=='y'11getch()==,Y')deletebyphone();return;))intdele(){charchoic;printf(“\t\t\tl-按電話號(hào)碼刪除2?按姓名刪除");printf("\t\t\t請選擇:");choic=getch();switch(choic)(case'l':deletebyphone();break;case'2':deletebyname();break;}return(O);}intsortbyname() 〃按姓名進(jìn)行排序(intij;structrecordtmp;for(i=l;i<num;i++){if(strcmp(student[i].name,student[i-l].name)<O){tmp=student[i];do{student[j+l]=student[j];j-;}while((strcmp(/student[j].name)<O&&j>=O));student[j+l]=tmp;})printf("\t\t\t排序成功,是否顯示?(y/n)");if(getch()=='y')list();return(O);intmain()prjntf(”\t\t************************************************\n”).printf("\t\t********welcometoTONGXUNLU?**??*?************\nH);printf("ヽt\t###########codebyXXXXX###################、バ);printf("\t\t**?*****???**************************************\p")?printf("按任意鍵進(jìn)入主菜單'n”);getch();intselectnum;while(l)(selectnum=menu_select();switch(selectnum)case0:adduser();break;}list();break;)(searchbyname();break;}(searchbyphone();break;)(adduser(); 〃這里插入,應(yīng)該能指定位置,不過意義不大,所以和添加記錄ー樣了。break;)sortbyname();break;}(dele();break;)(printf("BYEBYE!\n");systemCpause11);getchar();exit(O);)))getchar();return0;}5.歡迎使用電影俱樂部程序include<stdio.h>#include<string.h>include<stdlib.h>#include<math.h>#include<time.h>intn,nl;/?全局變量?/intN[3];/*上次輸入的信息不會(huì)丟失?/intyuefei=30;check();/?驗(yàn)證密碼ッmenul();quit();menu2();menu3();create。;/?建立檔案?/add();/?增加信息?/monfei();dvd();searchl();search2();printhuiyuan();printdvd();moon();structdvdA|charname[20];intnum;intsex;inthuifei;intday;intdvdl;intdvd2;intdvd3;}stul(100];structdvdB{intnum;charname[20];intk;}ddl[100];main()(pNntf(”*******************歡迎使用電影但樂部程序**********************,printf("\n\n\n\n輸入密碼:");if(check())menul();else{printf("密碼錯(cuò)誤'n“);printf("****************j青*****************\n”)?quit。;)}intcheck(){chara[2O]/str[]=',l";intcount;for(count=0;count<3;count++){gets(a);if(strcmp(a,str)==O)return1;elsecontinue;|return0;}intmenul(){FILE*fpl;inta;if((fpl=fopen("n.txt";'a+"))==NULL){printf("cannotopenfile");exit(O);}{fread(&N[l],sizeof(int),l,fpl);fread(&N[2],sizeof(int),l,fpl);}fclose(fpl);n=N[l];nl=N[2];moon();printf("\n1.檔案建立、n");printf("\n2.會(huì)員注冊、n");printf("\n3.會(huì)費(fèi)功能、n");printf("\n4.dvd信息、n");printf("\n5.瀏覽信息、n");printf{"\n6.查詢信息、n");printf("\n7.退出、n");printf("\n\n\n請選擇編號(hào):");scanf("%d",&a);switch(a){case1:{create();menul();}break;{add();menul();}break;{monfei();menul();}break;{dvd();menul();}break;menu2();break;menu3();break;quit();break;default:printf("編號(hào)錯(cuò)誤!\nH);menul();))intmenu2()inta;printf("信息瀏覽'n");printf("\n1.會(huì)員信息瀏覽'n");printf("\n2.dvd信息瀏覽、n");printf("\n3.返回上級(jí)菜單\n");printf("\n\n\n請輸入編號(hào):");scanf("%d",&a);switch(a)(printhuiyuan();break;printdvd();break;menul();break;default:printf("輸入編號(hào)錯(cuò)誤、n");menu2();}}create()(FILE*fp/fpl;inti;structdvdAstu2[100];structdvdBdd2[100];inty,m,d,sl;time_ttimep;structtm*p;time(&timep);p=localtime(&timep);/?取得當(dāng)?shù)貢r(shí)間?/m=l+p->tm_mon;d=p->tm_mday;sl=m*3O+d;printf("請輸入檔案的個(gè)數(shù):");scanf(”%d”,&n);N[O]=n;for(i=0;i<n;i++)(printf(”請輸入會(huì)員名:M);scanf("%s”,&stul[i].name);printf(”請輸入會(huì)員編號(hào);");scanf("%d”,&stul[i].num);printf(”請輸入會(huì)員性別:男1女2:");scanf("%d”,&stul[i].sex);fflush(stdin);printf(“請輸入充入的會(huì)費(fèi):");scanf("%d"z&stul[i].huifei);stul[i].day=sl;stul[i].dvdl=stul[i].dvd2=stul[i].dvd3=O;getchar();if((fp=fopen(,,huiyuan.txt";'w+"))==NULL){printf("cannotopenfile*');exit(O);)for(i=0;i<n;i++)fwrite(&stul[i],sizeof(structdvdA),lJp);fclose(fp);if((fp=fopen("huiyuan.txt";'r+"))==NULL){printf("cannotopenfile");exit(O);)for(i=0;i<n;i++){fread(&stu2[i]/sizeof(structdvdA),lJp);printf("姓名編號(hào)性別會(huì)費(fèi)\n");printf("%4s,%5d,%5d,%4d\n”,stu2[i].name,stu2[i].num,stu2[i].sex,stu2[i].huifei);)fclose(fp);printf("請輸入dvd檔案的個(gè)數(shù):");scanf(”%d”,&nl);N[2]=nl;for(i=0;i<nl;i++)(printf("請輸入dvd編號(hào):");scanf(”%d”,&ddl[i].num);printf(”請輸入dvd名;”);scanf("%s",&ddl[i].name);ddl[i].k=l;getchar();}if((fp=fopen("dvd.txt,,;,w+"))==NULL){printf("cannotopenfile");exit(O);)for(i=0;i<nl;i++)fwrite(&ddl[i],sizeof(structdvdB),l,fp);fclose(fp);if((fp=fopen("dvd.txt";'r+"))==NULL){printf("cannotopenfile");exit(O);}for(i=0;i<nl;i++){fread(&dd2[i]zsizeof(structdvdB),l,fp);printf("編號(hào)dvd名數(shù)量、バ);printf("%4d,%5s%d\n"zdd2[i].num,dd2[i].name,dd2[i].k);fclose(fp);if((fpl=fopen(,,n.txt",,,w+n))==NULL){printfC'cannotopenfile");exit{0};}{fwrite(&N[0],sizeof(int),l,fpl);fwrite(&N[2],sizeof(int),l,fpl);}fclose(fpl);add()(FILE*fp,*fpl;inti,a;structdvdAstu2[100];intm,d,sl;time_ttimep;structtm*p;time(&timep);p=localtime(&timep);/?取得當(dāng)?shù)貢r(shí)間?/m=l+p->tm_mon;d=p->tm_mday;sl=m*30+d;printf("請輸入增加會(huì)員檔案的個(gè)數(shù):scanf("%d",&a);for(i=n;i<(n+a);i++)(printf(”請輸入會(huì)員名:");scanf("%s",&stul[i].name);fflush(stdin);printf(“請輸入會(huì)員編號(hào):“);scanf(H%d",&stul[i].num);fflush(stdin);print耳,1請輸入會(huì)員性別:男!女2:");scanf("%d",&stul[i].sex);fflush(stdin);printf("請輸入初始的會(huì)費(fèi):");scanf("%d",&stul[i].huifei);stul[i].day=sl;stul[i].dvdl=stul[i].dvd2=stul[i].dvd3=0;getchar();}if((fp=fopen("huiyuan.txt,,/"a+"))==NULL){printf(Hcannotopenfile");exit(O);)for(i=n;i<(n+a);i++)fwrite(&stul[i],sizeof(structdvdA),l,fp);fclose(fp);n=n+a;if<(fp=fopen("huiyuan.txt";'r+"))==NULL){printf("cannotopenfile");exit(O);)for(i=0;i<n;i++)(fread(&stu2[i],sizeof(structdvdA),l,fp);printf("姓名編號(hào)性別會(huì)費(fèi)\n");printf("%4s,%5d,%5dz%4d\n"/stu2[i].name/stu2[i].num,stu2[i].sex,stu2[i].huifei);}fclose(fp);N[0]=n;if((fpl=fopen("n.txt"/"w+"))==NULL){printf("cannotopenfile");exit(O);)fwrite(&N[〇],sizeof(int),l,fpl);fclose(fpl);}monfei(){FILE*fp,*fpl;inti,c;charname[20];structdvdAstu2[100];printf("\n請輸入會(huì)員姓名:\n");scanf("%s",&name);if((fp=fopen("huiyuan.txt","r+"))==NULL){printf("cannotopenfile");exit(O);}for(i=0;i<n;i++){fread(&stu2[i],sizeof(structdvdA),l,fp);c=strcmp(name,stu2[i].name);if(c==O){printf("姓名編號(hào)性別會(huì)費(fèi)dvdldvd2dvd3\n");printf("%4s,%5d,%5d,%4d %4d %4d %4d\n",stu2[i].name,stu2[i].num,stu2[i].sex,stu2[i].huifei,stu2[i].dvdl,stu2[i].dvd2,stu2[i].dvd3);printf("請輸入你要充入會(huì)費(fèi)、バ);scanf(”%d”,&stu2[i].huifei);)}fclose(fp);if((fp=fopen("huiyuan.txt,,,"w+"))==NULL){printf("cannotopenfile");exit(O);)for(i=0;i<n;i++)fwrite(&stu2[i],sizeof(structdvdA),l,fp);fclose(fp);}dvd(){FILE*fpz*fpl;intしc;charname[20];structdvdAstu2[100];printf("\n請輸入會(huì)員姓名ヘバ);scanf(”%s”,&name);if((fp=fopen("huiyuan.txt"/"r+"))==NULL){printf("cannotopenfile");exit(O);)for(i=0;i<n;i++){fread(&stu2[i]/sizeof(structdvdA),l,fp);c=strcmp(namezstu2[i].name);if(c==O){printf("姓名編號(hào)性別會(huì)費(fèi)dvdldvd2dvd3\n");printf("%4s,%5d,%5d,%4d %4d %4d %4d\n",stu2[i].name/stu2[i].num,stu2[i].sex,stu2[i].huifei/stu2[i].dvdl,stu2[i].dvd2/stu2[i].dvd3);prin廿("請輸入你要修改后的函dl編號(hào):”);scanf("%d"z&stu2[i].dvdl);printf("\n請輸入你要修改后的dvd2編號(hào):");scanf("%d"z&stu2[i].dvd2);printf("\n請輸入你要修改后的dvd3編號(hào):");scanf("%d"z&stu2[i].dvd3);}}fclose(fp);if((fp=fopen("huiyuan.txt"z"w+"))==NULL){printf(ncannotopenfile");exit(O);)for(i=0;i<n;i++)fwrite(&stu2[i],sizeof(structdvdA)zl,fp);fclose(fp);menul();}moon()(FILE*fp;inti;structdvdAstu2[100];intm,d,sl,s2;time_ttimep;structtm*p;time(&timep);p=localtime(&timep);/?取得當(dāng)?shù)貢r(shí)間?/m=l+p->tm_mon;d=p->tm_mday;sl=m*30+d;if((fp=fopen("huiyuan.txt,7,a+"))==NULL){printf("cannotopenfile");exit{0};}for(i=0;i<n;i++){fread(&stu2[i]/sizeof(structdvdA),lJp);s2=(sl-stu2[i].day)^0;if(s2>0){stu2[i].huifei=stu2[i].huifei-yuefei*s2;stu2[i].day=sl;|)fclose(fp);if((fp=fopen("huiyuan.txt"z"w+"))==NULL){printf("cannotopenfile");exit(O);)for(i=0;i<n;i++)fwrite(&stu2[i],sizeof(structdvdA),l,fp);fclose(fp);}searchl(){FILE*fp,*fpl;inti,c;charname[20];structdvdAstu2[100];printf("\n請輸入會(huì)員姓名ヘバ);scanf("%s"z&name);if((fp=fopen("huiyuan.txtM/,,r+"))==NULL){printf(Hcannotopenfile");exit(O);)for(i=0;i<n;i++){fread(&stu2[i],sizeof(structdvdA)コ,fp);c=strcmp(name,stu2[i].name);if(c==O){printf("姓名編號(hào)性別會(huì)費(fèi)dvdldvdZdvd3\n");printf(”%4s,%5d,%5d,%4d %4d %4d %4d\nH,stu2[i].name,stu2[i].num,stu2[i].sex,stu2[i].huifei,stu2[i].dvdl,stu2[i].dvd2,stu2[i].dvd3);break;}}fclose(fp);menu3();)search2()|FILE*fp,*fpl;inti,c;structdvdBdd2[100];printf("\n請輸入dvd編號(hào):\n");scanf("%d",&c);if((fp=fopen(",dvd.txt","r+',))==NULL){printf("cannotopenfile");exit(O);}for(i=0;i<nl;i++){fread(&dd2[i],sizeof(structdvdB),l,fp);if(c==dd2[i].num){printf("編號(hào)dvd名數(shù)量、n");printf("%4d/%5s%d\n",dd2[i].num,dd2[i].name,dd2[i].k);break;)}fclose(fp);menu3();}printhuiyuan(){FILE*fp;inti;structdvdAstu2[100];if((fp=fopen("huiyuan.txt";'r+"))==NULL){printf("cannotopenfile");exit(O);}for(i=0;i<n;i++){fread(&stu2[i],sizeof(structdvdA),l,fp);printf("姓名編號(hào)性別會(huì)費(fèi)Xn");printf("%4s/%5d/%5d/%4d\n,,/stu2[i].name/stu2[i].num/stu2[i].sex/stu2[i].huifei);}fclose(fp);menu2();}printdvd(){FILE*fp;inti;structdvdBdd2[100];if((fp=fopen("dvd.txtM/,,r+H))==NULL){printf("cannotopenfile");exit(O);)for(i=0;i<nl;i++){fread(&dd2[i]/sizeof(structdvdB)ユfp);printf("編號(hào)dvd名數(shù)量、ザ;printf("%4d,%5s%4d\n",dd2[i].num,dd2[i].name,dd2[i].k);}fclose(fp);menu2();}menu3()(inta;printf("\n信息查詢\n");printf("\n1.按會(huì)員名查找、n");printf("\n2.按dvd查找'n");printf("\n3.返回上級(jí)菜單\n");printf("\n\n\n請輸入編號(hào):");scanf("%d",&a);switch(a)(searchl();break;search2();break;menul();break;default:printf("輸入編碼錯(cuò)誤、n");menu3();}quito{charch;printf("\n真的要退出?(Y/N)H);fflush(stdin);scanf(”%cツ&ch);if(ch=='Y'||ch=='y')printf("\n下次再來!!!");exit(O);menul();.歌星大獎(jiǎng)賽?成績結(jié)果表#include<stdio.h>#include<math.h>voidmain()(inta[10];inti,max,min,maxi,mini,sum,aver; 〃對變量進(jìn)行聲明sum=0;max=0;min=100;maxl=0;minl=100;print"'********************歌星大獎(jiǎng)賽?成績結(jié)果表********************、バトprintナ請10位評(píng)委打分,分?jǐn)?shù)在〇?100之間:'n");for(i=l;i<=10;i++)|printf("%d號(hào)評(píng)委所給的分?jǐn)?shù)為:",i);scanf("%d",&a[i]);if(a[i]>max)max=a[i];〃比較大小,得出最大值、最小值和10位評(píng)委的分?jǐn)?shù)總和if(a[i]<min)min=a[i];sum+=a[i];|printff,最髙分為%d分、n",max);printf("最低分為%d分、n",min);aver=(sum-max-min)^;printf("該選手的平均分為%d分、バ,aver);for(i=l;i<=10;i++) 〃與平均值作比較,得出差值最小的分?jǐn)?shù)(if(abs(a[i]-aver)<minl){minl=abs(a[i]-aver);}〃abs(x)函數(shù)的功能是求x的絕對值}for(i=l;i<=10;i++) 〃找出最公平的評(píng)委(if(abs(a[i]-aver)==minl){printf("最公平的評(píng)委是%d號(hào)、n”,i);}for(i=l;i<=10;i++) 〃與平均值作比較,得出差值最大的分?jǐn)?shù){if(abs(a[i]-aver)>maxl){maxl=abs(a[i]-aver);}}for(i=l;i<=10;i++) 〃找出最不公平的評(píng)委((if(abs(a[i]-aver)==maxl){printf("最不公平的評(píng)委是%d號(hào)、n,i);}}}.學(xué)生選課信息#include<stdio.h>#include<stdlib.h>structlesson /?課程結(jié)構(gòu)體?/(intnum;charname[10];charcharc[5];inttotaltime;intclasstime;intlabtime;intpoint;intstartterm;}les[9];structstudent /?選修結(jié)構(gòu)體?/(intstunum;intlesson[5];}stu[9];voidlesson() /?課程信息函數(shù)*/(FILE*fp;inti;printf(“請輸入課程信息,格式為:課程編號(hào)、課程名稱、課程性質(zhì)、總學(xué)時(shí)、授課學(xué)時(shí)、實(shí)驗(yàn)或上機(jī)學(xué)時(shí)、學(xué)分、開課學(xué)期、バ);if((fp二fopen(“所有課程信息.txt”Jw"))=NULL){printf(Herror");exit(0);)for(i=0;i<10;i++)scanf(”%d%s%s%d%d%d%d%d”,&les[i].num,les[i].name,les[i].chare,&les[i].totaltime,&les[i].classtime,&les[i].labtime,&les[i].point,&les[i].startterm);for(i=0;i<10;i++)fprintf(fp,"%d%s%s%d%d%d%d%d\n",les[i].num,les[i].name,les[i].charc,les[i].totaltime,les[i].classtime,les[i].labtime,les[i].point,les[i].startterm);fclose(fp);voidinput() /?學(xué)生選課錄入函數(shù)?/{FILE*fp,*hp;inti,j;if((fp=fopen("所有課程信息.txtソT))==NULL){printf("error");exit(0);}for(i=0;i<10;i++)fscanf(fp,"%d%s%s%d%d%d%d%d",&les[i].num,les[i].name,les[i],chare,&les[i],totaltime,&les[i].classtime,&les[i],labtime,&les[i].point,&les[i],startterm);fclose(fp);if((hp=fopen("學(xué)生選課信息.txt","w"))==NULL)(printf("error");exit(0);|for(i=0;i<10;i++){printf("請輸入學(xué)號(hào):ッ;scanf("%d",&stu[i].stunum);printf("可選擇的課程有:〇.語文、1.數(shù)學(xué)、2.英語、3.物理、4.化學(xué)、5.生物、6.體育、7.美術(shù)、8.音樂、9.C語言、n");for(j=0;j<6;j++){scanf("%d",&stu[i].lesson[j]);if(stu[i].lesson[j]<0&&stu[i].lesson[j]>9){printf("error");exit(0);}}}for(i=0;i<10;i++){fprintf(hp,"%d",stu[i].stunum);for(j=0;j<6;j++){fprintf(hp,"%d%s%s%d%d%d%d%d\n",les[stu[i].Iesson[j]].num,les[stu[i].lesson[j]].name,les[stu[i].lesson[j]].charc,les[stu[i].lesson[j]l.totaltime,les[stu[i].lesson[j]].classtime,les[stu[i].Iesson[j]].labtime,les[stu[i].lesson[j]].point,les[stu[i].lesson[j]].startterm);)}fclose(hp);voidoutput() /?課程信息瀏覽函數(shù)?/(FILE*fp;inti;if((fp=fopen(“所有課程信息.txピ,ザ)==NULL){printf("error");exit(0);}for(i=0;i<10;i++)fscanf(fp,"%d%s%s%d%d%d%d%d",&les[i].num,les[i].name,les[i].chare,&les[i].totaltime,&les[i].classtime,&les[i].labtime,&les[i].point,&les[i].startterm);for(i=0;i<10;i++)printf("%d%s%s%d%
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度房地產(chǎn)中介客戶信息保密協(xié)議范本2篇
- 二零二五年三方二手車交易風(fēng)險(xiǎn)防范及保險(xiǎn)合同2篇
- 二零二五年度企業(yè)合同管理培訓(xùn)與人才發(fā)展意見建議書3篇
- 護(hù)理本科專業(yè)課課程思政教學(xué)評(píng)價(jià)指標(biāo)體系的構(gòu)建
- 服裝知識(shí)培訓(xùn)課件
- 2025版綠色家居裝飾工程勞務(wù)合作合同2篇
- Unit 4《Lesson 3 My tidy bag》(說課稿)-2024-2025學(xué)年粵人版(2024)英語三年級(jí)上冊
- 工業(yè)機(jī)器人智能生產(chǎn)線升級(jí)改造擴(kuò)建項(xiàng)目可行性研究報(bào)告寫作模板-備案審批
- 二零二五年度房地產(chǎn)項(xiàng)目股權(quán)劃轉(zhuǎn)及融資合作協(xié)議3篇
- 湖南省長沙市2025年新高考適應(yīng)性考試生物學(xué)模擬試題(含答案)
- 智能制造企業(yè)數(shù)字化轉(zhuǎn)型建設(shè)方案
- (隱蔽)工程現(xiàn)場收方計(jì)量記錄表
- 病理生理學(xué)課件脂代謝紊亂
- 教師幽默朗誦節(jié)目《我愛上班》
- 《細(xì)胞工程學(xué)》考試復(fù)習(xí)題庫(帶答案)
- 中學(xué)課堂教學(xué)評(píng)價(jià)量表
- 食堂食材配送以及售后服務(wù)方案
- 稱量與天平培訓(xùn)試題及答案
- 塊單項(xiàng)活動(dòng)教學(xué)材料教案丹霞地貌
- 青年人應(yīng)該如何樹立正確的人生觀
- 開封辦公樓頂發(fā)光字制作預(yù)算單
評(píng)論
0/150
提交評(píng)論