C語(yǔ)言實(shí)現(xiàn)自行車(chē)存放管理系統(tǒng)
本文實(shí)例為大家分享了C語(yǔ)言實(shí)現(xiàn)自行車(chē)存放管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
系統(tǒng)包括以下內(nèi)容
1.數(shù)據(jù)錄入:錄入系統(tǒng)基本數(shù)據(jù),用數(shù)組或鏈表組織;
2.數(shù)據(jù)存儲(chǔ):用文件的形式將錄入的數(shù)據(jù)存儲(chǔ);
3.數(shù)據(jù)讀寫(xiě):對(duì)文件中的數(shù)據(jù)可以進(jìn)行讀寫(xiě)操作;
4.數(shù)據(jù)修改:可以對(duì)已存在的舊數(shù)據(jù)進(jìn)行修改操作;
5.數(shù)據(jù)插入:可以將新數(shù)據(jù)插入到任意指定的位置;
6.數(shù)據(jù)刪除:可以對(duì)已存在的舊數(shù)據(jù)進(jìn)行刪除操作;
7.數(shù)據(jù)查詢:按要求對(duì)數(shù)據(jù)進(jìn)行查詢,至少含兩項(xiàng)
簡(jiǎn)單查詢以及一項(xiàng)組合查詢;
8.數(shù)據(jù)統(tǒng)計(jì):按要求對(duì)數(shù)據(jù)進(jìn)行統(tǒng)計(jì)
含簡(jiǎn)單統(tǒng)計(jì)及綜合統(tǒng)計(jì);
9.數(shù)據(jù)排序:按要求對(duì)數(shù)據(jù)進(jìn)行排序
含升序排序及降序排序;
10.數(shù)據(jù)報(bào)表:按要求對(duì)數(shù)據(jù)打印報(bào)表,
依規(guī)定的報(bào)表格式對(duì)數(shù)據(jù)打印報(bào)表;
11.界面:設(shè)計(jì)總體菜單界面。
附加項(xiàng)目:
登錄、注冊(cè)部分;
(密碼設(shè)置密碼的隱式輸出、簡(jiǎn)單的加密解密)
附代碼:
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> ? struct bicycle{ ?? ?char tele_num[12];//用戶的電話號(hào)碼? ?? ?char name[13];//用戶的姓名 ?? ?char sex[7];//用戶的性別? ?? ?char bic_num[12];//自行車(chē)的編號(hào)? ?? ?struct bicycle *next; }; ? ? int iCount=0; struct bicycle *pHead=NULL; ? void key();? void menu(); void create(); void print();? void insert(); void search(); void dele(); void modify(); void excheng(struct bicycle *pStra,struct bicycle *Midd);? void sort();? ? int main(){ ?? ? ?? ? ? ? menu(); ?? ?printf("123"); ?? ? ?? ?return 0; } ? //密碼管理頁(yè)面? void key(){ ?? ?? ?char key[20],m[20]; ?? ?FILE *k; ? ? k=fopen("key.txt","r"); ?? ?if(k==NULL) ?? ?{ ? k=fopen("key.txt","wt"); ?? ??? ?printf("請(qǐng)創(chuàng)建管理密碼:\n"); ?? ??? ?scanf("%s",key); ?? ??? ?fprintf(k,"%s",key); ?? ??? ?fclose(k); ?? ??? ?printf("恭喜您創(chuàng)建成功!\n"); ? ? ? ? getchar(); ?? ? ? ?printf("按任意鍵繼續(xù)..."); ?? ? ? ?getchar(); ?? ??? ?return ; ?? ?} ? ? ?else ?? ? { ?fscanf(k,"%s",m); ?? ? fclose(k); ?? ??? ?printf("請(qǐng)輸入管理密碼:"); ?? ??? ?scanf("%s",key); ?? ??? ?if(strcmp(m,key)==0) ?? ??? ?{ ?? ??? ? printf("密碼正確!\n"); ? ? ? ? getchar(); ?? ? ? ?printf("按任意鍵繼續(xù)..."); ?? ? ? ?getchar(); ?? ??? ?return ; ?? ??? ?} ?? ??? ?else ?? ??? ?{ ? ? ? ? ? ? printf("密碼錯(cuò)誤!\n"); ? ? ? ? getchar(); ?? ? ? ?printf("按任意鍵繼續(xù)..."); ?? ? ? ?getchar(); ?? ??? ?return ; ?? ??? ?} ?? ? } } ? //顯示景點(diǎn)的信息? void menu(){ ?? ?key();? ?? ?int select=-1; ? ?? ?while(select!=0){ ? ?? ?system("cls");? ? ? printf("\n\n\t\t\t\t\t\t\t==============歡迎使用自行車(chē)管理系統(tǒng)==============\n"); ?? ?printf("\t\t\t\t\t\t\t\t=======請(qǐng)選擇功能列表=======\n"); ? ? printf("\t\t\t\t\t\t\t\t1.錄入自行車(chē)的信息LV5\n"); ? ? printf("\t\t\t\t\t\t\t\t2.修改自行車(chē)的信息LV5\n"); ? ? printf("\t\t\t\t\t\t\t\t3.刪除自行車(chē)的信息LV5\n"); ?? ?printf("\t\t\t\t\t\t\t\t4.查詢自行車(chē)的信息LV5\n");? ?? ?printf("\t\t\t\t\t\t\t\t5.打印自行車(chē)的信息LV5\n"); ?? ?printf("\t\t\t\t\t\t\t\t6.自行車(chē)信息的排序LV5\n"); ?? ?printf("\t\t\t\t\t\t\t\t7.插入自行車(chē)的信息LV5\n"); ? ?? ?printf("\t\t\t\t\t\t\t\t0.退 ? 出 ? 菜 ?單LV5\n"); ? ? printf("\n請(qǐng)選擇:"); ? ? scanf("%d",&select); ? ? switch(select){ ? ? ? case 1: ? ? ? ?? ?create();? ?? ??? ? ?break;? ? ? ? case 2: ? ? ? ?? ?modify();? ? ? ? ? ?break; ? ? ? case 3: ? ? ? dele();? ? ? ? ? break; ? ? ? case 4: ? ?? ??? ?search();? ? ? ? ? break; ? ? ? ? ? case 5: ? ?? ??? ?print();? ? ? ? ? break; ? ? ? ? case 6: ? ?? ??? ?sort();? ? ? ? ? break; ? ? ? ? case 7: ? ?? ??? ?insert();? ? ? ? ? break; ? ? ? ? case 0:break; ? ? ? default: ? ? ? ? exit(1); ? ? ? ? break; ? ? } ? }?? ? ?? ? ?? ? }? ? //創(chuàng)建鏈表函數(shù) void create(){ ?? ?//頁(yè)面優(yōu)化 ?? ?system("cls"); ?? ? ?? ?struct bicycle *pEnd,*pNew; ?? ?struct bicycle *p; ? ? pEnd=pNew=(struct bicycle *)malloc(sizeof(struct bicycle)); ? ?? ?printf("請(qǐng)輸入存放自行車(chē)的信息(退出請(qǐng)按0):\n"); ? ?? ?//錄入自行車(chē)編號(hào),編號(hào)不可以重復(fù) ? ? int flag1=1,flag2,n;? ?? ?struct bicycle *pTemp; ?? ?printf("\n自行車(chē)的編號(hào)(退出請(qǐng)按0):"); ? ? scanf("%s",pNew->bic_num); ? ?? ? ? while(flag1){ ?? ??? ?if(strcmp(pNew->bic_num,"0")==0) ?{ ?? ??? ??? ?flag1=1; ?? ??? ??? ?break; ?? ??? ?} ? ?? ??? ?else{ ?? ??? ??? ?pTemp=pHead; ?? ??? ??? ?n=iCount; ?? ??? ??? ?flag2=1; ? ?? ??? ??? ?while(n&&flag2){ ?? ??? ??? ? ? if(strcmp(pTemp->bic_num,pNew->bic_num)==0) ?flag2=0; ?? ? ? ? ? ? ? pTemp=pTemp->next; ?? ??? ? ? ? ? n=n-1; ?? ??? ??? ?}?? ? ?? ??? ??? ? ?? ??? ??? ?if(flag2==0){? ?? ??? ??? ??? ?printf("請(qǐng)重新輸入,自行車(chē)編號(hào)%s存在!(退出請(qǐng)按0):\n",pNew->bic_num); ?? ??? ??? ??? ?printf("自行車(chē)的編號(hào):");? ?? ??? ??? ??? ?scanf("%s",pNew->bic_num);? ?? ??? ??? ??? ?flag1=1; ?? ??? ??? ?} ? ?? ??? ??? ?if(flag2==1) flag1=0; ?? ??? ?} ?? ?} ?? ? ?? ?//錄入其他信息,如果flag1=0,則表明要退出,那么其他信息不用再錄 ? ? if(flag1!=1){?? ? ?? ??? ?printf("姓名:"); ?? ? ? ?scanf("%s",pNew->name); ?? ? ? ? ?? ? ? ?//性別只能輸入female或male,否則是不規(guī)范的 ?? ??? ?while(1){ ?? ??? ? ?printf("性別(female或male):"); ?? ? ? ? ?scanf("%s",pNew->sex); ?? ??? ? ?if(strcmp(pNew->sex,"female")==0||strcmp(pNew->sex,"male")==0) break; ?? ??? ? ?else printf("性別輸入不規(guī)范,請(qǐng)核對(duì)后重輸!\n"); ?? ??? ?} ?? ? ? ? ?? ? ? ?//電話必須11位數(shù),否則是不規(guī)范的 ?? ??? ?while(1){ ?? ??? ? ?printf("電話(11位數(shù)):"); ?? ? ? ? ?scanf("%s",pNew->tele_num); ?? ??? ? ?if(strlen(pNew->tele_num)==11) break; ?? ??? ? ?else printf("電話輸入不規(guī)范,必須11位數(shù)!\n"); ?? ??? ?} ?? ? ? ? ?? ?} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ?while(strcmp(pNew->bic_num,"0")!=0) ?? ?{ ?? ??? ?iCount++; ?? ??? ? ?? ? ? ?if(pHead==NULL){ ?? ??? ??? ? pNew->next=NULL; ?? ??? ??? ? pEnd=pNew; ?? ??? ??? ? pHead=pNew; ?? ??? ??? ?} ? ?? ? ?? ??? ?else{ ?? ??? ??? ? ?? ??? ? p=pHead;? ?? ? ?? ??? ?while(p&&p->next!=NULL) p=p->next; ?? ??? ?{ ?? ? ? ? ?p->next=pNew; ?? ??? ? ?pNew->next=NULL; ?? ??? ?} ?? ??? ?} ? ? ? pNew=(struct bicycle *)malloc(sizeof(struct bicycle)); ? ? ?? ? ?printf("\n自行車(chē)的編號(hào)(退出請(qǐng)按0):"); ? ? ? ? ? ? ? ? ? ? ? scanf("%s",pNew->bic_num); ? ? ? flag1=1;//每次循環(huán)結(jié)束flag1=1退出;flag1=0則繼續(xù),所以要值0 ? ? ? while(flag1){ ? ? ? ?? ? ?? ??? ?if(strcmp(pNew->bic_num,"0")==0){ ?? ??? ??? ?flag1=1; ?? ??? ??? ?break; ?? ??? ?} ? ?? ??? ?else{ ?? ??? ??? ?pTemp=pHead; ?? ??? ??? ?n=iCount; ?? ??? ??? ?flag2=1; ? ?? ??? ??? ?while(n&&flag2){ ?? ??? ??? ? ? if(strcmp(pTemp->bic_num,pNew->bic_num)==0) ?flag2=0; ?? ? ? ? ? ? ? pTemp=pTemp->next; ?? ??? ? ? ? ? n=n-1; ?? ??? ??? ?}?? ? ?? ??? ??? ? ?? ??? ??? ?if(flag2==0) {? ?? ??? ??? ??? ?printf("請(qǐng)重新輸入,自行車(chē)的編號(hào)%s存在!(退出請(qǐng)按0):\n",pNew->bic_num); ?? ??? ??? ??? ?printf("自行車(chē)的編號(hào):");? ?? ??? ??? ??? ?scanf("%s",pNew->bic_num);? ?? ??? ??? ??? ?flag1=1; ?? ??? ??? ?} ? ?? ??? ??? ?if(flag2==1) flag1=0; ?? ??? ?} ?? ?} ?? ? ?? ?//錄入其他信息,如果flag1=0,則表明要退出,那么其他信息不用再錄 ? ? if(flag1!=1){?? ? ?? ??? ?printf("姓名:"); ?? ? ? ?scanf("%s",pNew->name); ?? ? ? ? ?? ? ? ?//性別只能輸入female或male,否則是不規(guī)范的 ?? ??? ?while(1){ ?? ??? ? ?printf("性別(female或male):"); ?? ? ? ? ?scanf("%s",pNew->sex); ?? ??? ? ?if(strcmp(pNew->sex,"female")==0||strcmp(pNew->sex,"male")==0) break; ?? ??? ? ?else printf("性別輸入不規(guī)范,請(qǐng)核對(duì)后重輸!\n"); ?? ??? ?} ?? ? ? ? ?? ? ? ?//電話必須11位數(shù),否則是不規(guī)范的 ?? ??? ?while(1){ ?? ??? ? ?printf("電話(11位數(shù)):"); ?? ? ? ? ?scanf("%s",pNew->tele_num); ?? ??? ? ?if(strlen(pNew->tele_num)==11) break; ?? ??? ? ?else printf("電話輸入不規(guī)范,必須11位數(shù)!\n"); ?? ??? ?} ?? ? ? ? ?? ?} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//22 ?? ??? ? ?? ?} ? ?? ?free(pNew); } ? //輸出鏈表自行車(chē)的信息 void print(){ ?? ? ?? ?//頁(yè)面優(yōu)化 ?? ?system("cls"); ?? ?printf("\n\n\t\t\t\t===================5.打印自行車(chē)的信息===================\n");? ? ?? ?struct bicycle *pTemp; ?? ?int iIndex=1; ?? ? ?? ?printf("**********本名單中共有%d個(gè)自行車(chē)信息,所有的信息如下:**********\n",iCount); ?? ?printf("序號(hào) 姓名 ?性別 ?電話 自行車(chē)編號(hào) \n"); ?? ?pTemp=pHead; ? ?? ?while(pTemp!=NULL){ ?? ??? ?printf("%d ?%s ?%s ?%s ?%s\n",iIndex,pTemp->name,pTemp->sex,pTemp->tele_num,pTemp->bic_num); ?? ??? ?pTemp=pTemp->next; ?? ??? ?iIndex++; ?? ?} ?? ?printf("按任意鍵返回上一級(jí)");? ? ?getch(); } ? //插入自行車(chē)的信息 void insert(){ ?? ?//頁(yè)面優(yōu)化 ?? ?system("cls"); ?? ?printf("\n\n\t\t\t\t===================7.插入自行車(chē)的信息===================\n");? ?? ?printf("#\n說(shuō)明:插入任意位置都可以\n#"); ?? ?create(); ? ?printf("插入信息成功,");? ? ?printf("按任意鍵返回上一級(jí)");? ? ?getch(); }? ? //信息查詢函數(shù) void search(){? ?? ?//頁(yè)面優(yōu)化 ?? ? ?? ?printf("\n\n\t\t\t\t===================4.查詢自行車(chē)的信息===================");? ? ?? ?int select=-1; ?? ?while(select!=0){ ?? ? ? system("cls"); ? ? ? ?printf("\n\t\t=======請(qǐng)選擇功能列表=======\n"); ? ? ? ?printf("\t\t\t1.按自行車(chē)的編號(hào)查詢(lv4)\n"); ? ? ? ?printf("\t\t\t2.按 ? 姓 ?名 ?查 詢 (lv1)\n"); ? ? ? ?printf("\t\t\t0.退出此頁(yè)面(lv4)\n"); ?? ? ? ? ?printf("請(qǐng)選擇:"); ? ? ? ?scanf("%d",&select); ? ?? ? ? ? ? ?? ? ? int flag=1,flag1=1; ?? ? ? char number[12]; ?? ? ? char name[12]; ?? ? ? struct bicycle *pTemp=pHead; ? ?? ? ? //按自行車(chē)的編號(hào)查詢 ?? ? ? if(select==1){ ?? ? ? ?? ? ?? ? ? printf("請(qǐng)輸入你要查找的自行車(chē)編號(hào):"); ?? ? ? scanf("%s",number); ?? ? ? ? ? while(pTemp!=NULL&&flag) ?? ??? ? ? { ?? ??? ? ? ? if(strcmp(pTemp->bic_num,number)==0) ?? ??? ??? ? {? ?? ??? ??? ??? ?printf("%s找到了,具體信息如下:\n\n",number); ?? ??? ??? ??? ? ?? ??? ??? ??? ?printf("\t姓名 ?性別 ?電話 自行車(chē)編號(hào) \n"); ?? ??? ??? ??? ?printf("\t%s ?%s ?%s ?%s\n",pTemp->name,pTemp->sex,pTemp->tele_num,pTemp->bic_num); ?? ??? ??? ??? ? printf("\n"); ?? ??? ??? ??? ? flag=0;? ?? ??? ??? ? } ?? ? ? ? ? ? pTemp=pTemp->next; ?? ??? ? ? } ?? ? ? if(flag==1) ?printf("編號(hào)%s不存在!\n",number); ?? ? ? } ? ?? ? ? //按姓名查詢 ?? ? ? if(select==2){ ?? ? ? printf("請(qǐng)輸入你要查找的姓名:"); ?? ? ? scanf("%s",name); ?? ? ? ? ? while(pTemp!=NULL&&flag) ?? ??? ? ? { ?? ??? ? ? ? if(strcmp(pTemp->name,name)==0)? ?? ??? ??? ? {? ?? ??? ??? ??? ? printf("%s找到了,具體信息如下\n",name); ?? ?? ??? ??? ??? ? ?printf("\t姓名 ?性別 ?電話 自行車(chē)編號(hào) \n"); ?? ??? ??? ??? ?printf("\t%s ?%s ?%s ?%s\n",pTemp->name,pTemp->sex,pTemp->tele_num,pTemp->bic_num); ?? ??? ??? ??? ? printf("\n"); ?? ??? ??? ??? ? flag=0; ? ?? ??? ??? ? } ?? ? ? ? ? ? pTemp=pTemp->next; ?? ??? ? ? } ?? ? ? if(flag==1) ?printf("姓名%s不存在!",name); ?? ? ? } ?? ?printf("按任意鍵返回上一級(jí)"); ?? ?getch(); ?? ?} } ? //刪除信息函數(shù) void dele(){ ?? ?//頁(yè)面優(yōu)化 ?? ?system("cls"); ?? ?printf("\n\n\t\t\t\t===================3.刪除自行車(chē)的信息(按編號(hào))===================");? ? ? ? int select=-1;? ?? ?while(select!=0){ ?? ? ?? ? ? ? ?printf("\n\t\t=======請(qǐng)選擇功能列表=======\n"); ? ? ? ?printf("\t\t\t1.按自行車(chē)的編號(hào)刪除(lv4)\n"); ? ? ? ?printf("\t\t\t2.按 ? 姓 ?名 ?刪 除 (lv1)\n"); ? ? ? ?printf("\t\t\t0.退出此頁(yè)面(lv4)\n"); ?? ? ? ? ?printf("請(qǐng)選擇:"); ? ? ? ?scanf("%d",&select); ? ?? ? ? if(select==0) return; ?? ?else if(select==1||select==2) break; ?? ?else printf("輸入有誤請(qǐng)重新輸入\n"); } ? if(select==1){ ?? ??? ? ?? ? ? ?if(iCount==0) ?printf("\n\n暫無(wú)數(shù)據(jù)無(wú)法進(jìn)行此操作,按任意鍵退出!\n"); ?? ??? ?else ?? ? ? ?{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//33 ?? ? ?? ??? ?char number[12]; ?? ??? ?int ?i,flag=1; ?? ??? ?char option; ?? ??? ?struct bicycle *pTemp; ?? ??? ?struct bicycle *pPre; ?? ??? ?pTemp=pHead; ?? ? ?? ??? ?int iIndex=0; ?? ??? ?printf("\n請(qǐng)輸入要?jiǎng)h除自行車(chē)的編號(hào):"); ?? ? ? ?scanf("%s",number); ?? ? ?? ??? ?while(pTemp!=NULL&&flag){ ?? ??? ??? ?if(strcmp(pTemp->bic_num,number)==0){ ?? ??? ??? ??? ?printf("\n%s找到了,將要?jiǎng)h除的信息如下\n\n",number); ?? ??? ??? ??? ?//顯示將要?jiǎng)h除人的信息 ?? ??? ??? ??? ? printf("\t姓名 ?性別 ?電話 自行車(chē)編號(hào) \n"); ?? ??? ??? ??? ?printf("\t%s ?%s ?%s ?%s\n",pTemp->name,pTemp->sex,pTemp->tele_num,pTemp->bic_num); ?? ??? ??? ??? ? printf("\n"); ?? ??? ??? ??? ??? ? flag=0;? ?? ??? ??? ??? ??? ?? ?? ??? ??? ??? ?printf("確認(rèn)刪除請(qǐng)輸1,否則按任意數(shù)字鍵退出\n"); ?? ??? ??? ??? ?scanf("%d",&option); ?? ??? ??? ?} ?? ? ?? ? ?? ??? ? ? ?pTemp=pTemp->next; ?? ??? ??? ?iIndex++; ?? ??? ?} ?? ??? ?if(flag==1) ?{printf("編號(hào)%s不存在!",number); ?return;} ?? ? ?? ? ?? ? ?? ? ? ? ? if(option==1){ ?? ??? ? ? ?pTemp=pHead; ?? ? ? ??? ?pPre=pTemp;//可能多余 ?? ??? ? ? ?//printf("----------刪除第%d個(gè)學(xué)生----------\n",iIndex); ?? ? ?? ??? ? ? if(iIndex!=1) ?? ??? ? ? { ?? ??? ? ? ? ? for(i=1;i<iIndex;i++) ?? ??? ??? ? ? { ?? ??? ??? ? ? pPre=pTemp; ?? ??? ??? ? ? pTemp=pTemp->next; ?? ??? ??? ? ? } ?? ? ?? ? ? ? ? ??? ?pPre->next=pTemp->next; ?? ? ?? ??? ? ? } ?? ? ?? ? ?? ??? ? ?if(iIndex==1)?? ?pHead=pTemp->next; ?? ??? ? ?free(pTemp); ?? ? ? ? ?iCount--; ?? ??? ? ?printf("刪除成功按任意鍵退出!"); ?? ??? ?} ?? ? ? else ?printf("刪除失敗按任意鍵退出!"); ?? ??? ?} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //33 ?? ? ? ? ?? ??? ?getch(); ?? ??? ? } else{ ?? ? ?? ? ? ? if(iCount==0) ?printf("\n\n暫無(wú)數(shù)據(jù)無(wú)法進(jìn)行此操作,按任意鍵退出!\n"); ?? ?else ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//33 ? ?? ?char name[12]; ?? ?int ?i,flag=1; ?? ?char option; ?? ?struct bicycle *pTemp; ?? ?struct bicycle *pPre; ?? ?pTemp=pHead; ? ?? ?int iIndex=0; ?? ?printf("\n請(qǐng)輸入要?jiǎng)h除自行車(chē)對(duì)應(yīng)戶主的姓名:"); ? ? scanf("%s",name); ? ?? ?while(pTemp!=NULL&&flag){ ?? ??? ?if(strcmp(pTemp->name,name)==0){ ?? ??? ??? ?printf("\n%s找到了,將要?jiǎng)h除的信息如下\n\n",name); ?? ??? ??? ?//顯示將要?jiǎng)h除人的信息 ?? ??? ??? ? printf("\t姓名 ?性別 ?電話 自行車(chē)編號(hào) \n"); ?? ??? ??? ?printf("\t%s ?%s ?%s ?%s\n",pTemp->name,pTemp->sex,pTemp->tele_num,pTemp->bic_num); ?? ??? ??? ? printf("\n"); ?? ??? ??? ??? ? flag=0;? ?? ??? ??? ??? ?? ?? ??? ??? ?printf("確認(rèn)刪除請(qǐng)輸1,否則按任意數(shù)字鍵退出\n"); ?? ??? ??? ?scanf("%d",&option); ?? ??? ?} ? ? ?? ? ? ?pTemp=pTemp->next; ?? ??? ?iIndex++; ?? ?} ?? ?if(flag==1) ?{printf("姓名%s不存在!",name); ?return;} ? ? ? ? ? ? ?if(option==1){ ?? ? ? ?pTemp=pHead; ? ? ?? ?pPre=pTemp;//可能多余 ?? ? ? ?//printf("----------刪除第%d個(gè)學(xué)生----------\n",iIndex); ? ?? ? ? if(iIndex!=1) ?? ? ? { ?? ? ? ? ? for(i=1;i<iIndex;i++) ?? ??? ? ? { ?? ??? ? ? pPre=pTemp; ?? ??? ? ? pTemp=pTemp->next; ?? ??? ? ? } ? ? ? ? ? ?? ?pPre->next=pTemp->next; ? ?? ? ? } ? ? ?? ? ?if(iIndex==1)?? ?pHead=pTemp->next; ?? ? ?free(pTemp); ? ? ? iCount--; ?? ? ?printf("刪除成功按任意鍵退出!"); ?? ?} ? ?else ?printf("刪除失敗按任意鍵退出!"); ?? ?} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //33 ? ?? ?? ?getch(); } ? } ? //2.修改自行車(chē)的信息 void modify(){ ?? ? ?? ?//頁(yè)面優(yōu)化 ?? ?system("cls"); ?? ?printf("\n\n\t\t\t\t===================2.修改自行車(chē)的信息===================");? ? ?? ?int post; ?? ?int flag=1,flag1; ?? ?char number[12]; ?? ?struct bicycle *pTemp=pHead,*pPre=pTemp; ?? ? ?? ?printf("\n請(qǐng)輸入你要修改自行車(chē)信息對(duì)應(yīng)自行車(chē)的編號(hào):"); ?? ?scanf("%s",number); ?? ? ?? ?while(pTemp!=NULL&&flag) ?? ?{ ? ?? ??? ?if(strcmp(pTemp->bic_num,number)==0)? ?? ??? ?{ ?? ??? ??? ?printf("將要修改的學(xué)號(hào)%s具體信息如下\n",number); ?? ??? ??? ? ?printf("\t姓名 ?性別 ?電話 自行車(chē)編號(hào) \n"); ?? ??? ??? ?printf("\t%s ?%s ?%s ?%s\n",pTemp->name,pTemp->sex,pTemp->tele_num,pTemp->bic_num); ?? ??? ??? ? printf("\n"); ?? ??? ??? ? flag=0;? ?? ??? ?} ? ? ? ? pPre=pTemp;//保存pTemp ?? ? ? ?pTemp=pTemp->next; ?? ?} ?? ? ?? ?if(flag==1) ?printf("你要修改的學(xué)號(hào)%s不存在!",number); ?? ?else? ?? ?{ ?? ??? ?printf("確認(rèn)修改請(qǐng)按1,放棄請(qǐng)按任意數(shù)字鍵!\n請(qǐng)選擇:"); ?? ??? ?scanf("%d",&post); ?? ??? ? ?? ??? ?while(post==1) ?? ??? ?{ ?? ??? ??? ?printf("請(qǐng)選擇你要修改的項(xiàng)目(1.姓名 2.性別 3.電話號(hào)碼 4.自行車(chē)的編號(hào) 5.修改全部)\n"); ?? ??? ??? ?scanf("%d",&flag1); ? ? ? ? ? ? ?if(flag1==1) ?? ??? ? ? { ?? ??? ??? ? ? printf("新姓名:"); ?? ??? ??? ? ? scanf("%s",pPre->name); ?? ??? ??? ? ? printf("修改完成,按任意鍵退出!"); ?? ??? ? ? } ? ?? ??? ? ? else if(flag1==2) ?? ??? ? ? { ?? ??? ??? ? ? printf("新性別:"); ?? ??? ??? ? ? scanf("%s",pPre->sex); ?? ??? ??? ? ? printf("修改完成,按任意鍵退出!"); ?? ??? ? ? } ? ?? ??? ? ? else if(flag1==3) ?? ??? ? ? { ?? ??? ? ? ?? ? ?? ??? ??? ? ?while(1){ ?? ??? ??? ? ?printf("電話(11位數(shù)):"); ?? ??? ? ? ? ?scanf("%s",pPre->tele_num); ?? ??? ??? ? ?if(strlen(pPre->tele_num)==11) break; ?? ??? ??? ? ?else printf("電話輸入不規(guī)范,必須11位數(shù)!\n"); ?? ??? ??? ??? ?}?? ? ?? ??? ??? ??? ? ?? ??? ??? ? ? printf("修改完成,按任意鍵退出!"); ?? ??? ? ? } ? ?? ??? ? ? else if(flag1==4) ?? ??? ? ? { ?? ??? ??? ? ? printf("新編號(hào):"); ?? ??? ??? ? ? scanf("%d",&pPre->bic_num); ?? ??? ??? ? ? printf("修改完成,按任意鍵退出!"); ?? ??? ? ? } ? ?? ??? ??? ?else{ ?? ??? ??? ??? ? ?? ??? ??? ? ? printf("新姓名:"); ?? ??? ??? ? ? scanf("%s",pPre->name); ?? ??? ??? ? ? ?? ??? ??? ? ? printf("新性別:"); ?? ??? ??? ? ? scanf("%s",pPre->sex); ?? ??? ? ? ?? ? ?? ??? ??? ? ?while(1){ ?? ??? ??? ? ?printf("電話(11位數(shù)):"); ?? ??? ? ? ? ?scanf("%s",pPre->tele_num); ?? ??? ??? ? ?if(strlen(pPre->tele_num)==11) break; ?? ??? ??? ? ?else printf("電話輸入不規(guī)范,必須11位數(shù)!\n"); ?? ??? ??? ?}?? ? ?? ??? ??? ??? ? ?? ??? ??? ? ? printf("新編號(hào):"); ?? ??? ??? ? ? scanf("%s",pPre->bic_num); ?? ??? ??? ? ?? ??? ??? ?} ?? ??? ??? ?break;?? ? ?? ??? ?} ?? ? ?? ? ?? ?} ? ?? ?printf("修改完成,按任意鍵退出");? ?? ?getch(); ? } ? //交換函數(shù) void excheng(struct bicycle *pStra,struct bicycle *pMidd){ ?? ?int t; ?? ?struct bicycle *pTemp; ?? ?pTemp=(struct bicycle *)malloc(sizeof(struct bicycle)); ? ?? ?strcpy(pTemp->tele_num,pStra->tele_num); ?? ?strcpy(pStra->tele_num,pMidd->tele_num); ? ? strcpy(pMidd->tele_num,pTemp->tele_num); ? ?? ?strcpy(pTemp->bic_num,pStra->bic_num); ?? ?strcpy(pStra->bic_num,pMidd->bic_num); ? ? strcpy(pMidd->bic_num,pTemp->bic_num); ? ?? ?? ?strcpy(pTemp->name,pStra->name); ? ? strcpy(pStra->name,pMidd->name); ?? ?strcpy(pMidd->name,pTemp->name); ? ?? ?strcpy(pTemp->sex,pStra->sex); ? ? strcpy(pStra->sex,pMidd->sex); ?? ?strcpy(pMidd->sex,pTemp->sex); ? ?? ?free(pTemp); ? } ? //6.自行車(chē)信息的排序 void sort(){ ?? ? ?? ?//頁(yè)面優(yōu)化 ?? ?printf("\n\n\t\t===================4.排序系統(tǒng)===================");? ? ? ? int i,j; ?? ?struct bicycle *pStra,*pMidd; ? ?? ?int result; ?? ?int select=-1; ?? ?while(select!=0) ?? ?{ ?? ? ? system("cls"); ? ? ? ?printf("\n\t\t\t=======請(qǐng)選擇功能列表=======\n"); ? ? ? ?printf("\t\t\t1.按自行車(chē)編號(hào)升序排序(lv4)\n"); ? ? ? ?printf("\t\t\t2.按自行車(chē)編號(hào)降序排序(lv1)\n"); ?? ? ? printf("\t\t\t3.按姓名升序排序(lv4)\n"); ? ? ? ?printf("\t\t\t4.按姓名降序排序(lv1)\n"); ? ? ? ?printf("\t\t\t0.退出此頁(yè)面(lv4)\n"); ?? ? ? ? ?printf("請(qǐng)選擇:"); ? ? ? ?scanf("%d",&select); ? ?? ??? ?result=select; ?? ??? ?if(select!=1&&select!=2&&select!=3&&select!=4) return; ?? ??? ? ? ?? ?pStra=pHead; ?? ?pMidd=pStra->next; ?? ? ?? ? ? ? ?for(i=0;i<iCount;i++) ?? ? { ?? ??? ?pStra=pHead; ?? ? ? ?pMidd=pStra->next; ? ?? ??? ? ?for(j=0;j<iCount-i-1&&pMidd!=NULL;j++) ?? ??? ? ?{ ?? ??? ??? ? ?if(result==1) ?{if(strcmp(pStra->bic_num,pMidd->bic_num)>0) ? ? ? ? ? excheng(pStra,pMidd);} ?? ??? ??? ? ?else if(result==2) ?{if(strcmp(pStra->bic_num,pMidd->bic_num)<0) ? ? ?excheng(pStra,pMidd);} ?? ??? ??? ? ?else if(result==3) ?{if(strcmp(pStra->name,pMidd->name)>0) ? ?excheng(pStra,pMidd);} ?? ??? ??? ? ?else if(result==4) ?{if(strcmp(pStra->name,pMidd->name)<0) ? ?excheng(pStra,pMidd);} ?? ??? ??? ?pStra=pMidd; ?? ??? ??? ?pMidd=pMidd->next; ?? ??? ? ?} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ?? ? } ? ? ?printf("\t\t\t5.顯示排完序后的結(jié)果為:\n\n"); ?printf("------------------------------------------------------"); ??? ?struct bicycle *pTemp; ?? ?int iIndex=1; ?? ? ?? ?printf("**********本名單中共有%d個(gè)自行車(chē)信息,所有的信息如下:**********\n",iCount); ?? ?printf("序號(hào) 姓名 ?性別 ?電話 自行車(chē)編號(hào) \n"); ?? ?pTemp=pHead; ? ?? ?while(pTemp!=NULL){ ?? ??? ?printf("%d ?%s ?%s ?%s ?%s\n",iIndex,pTemp->name,pTemp->sex,pTemp->tele_num,pTemp->bic_num); ?? ??? ?pTemp=pTemp->next; ?? ??? ?iIndex++; ?? ?} ? ?printf("------------------------------------------------------"); ? ? ?printf("\n\n排序成功,按任意鍵返回!"); ? ?? ?getch(); } ? }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C語(yǔ)言break和continue的語(yǔ)句用法
這篇文章主要介紹了C語(yǔ)言break和continue的語(yǔ)句用法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-04-04C++實(shí)現(xiàn)商店倉(cāng)庫(kù)管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)商店倉(cāng)庫(kù)管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03C++ OpenCV實(shí)戰(zhàn)之網(wǎng)孔檢測(cè)的實(shí)現(xiàn)
這篇文章主要介紹了如何利用C++和OpenCV實(shí)現(xiàn)網(wǎng)孔檢測(cè),文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)OpenCV有一定幫助,感興趣的小伙伴可以了解一下2022-05-05C語(yǔ)言編程銀行ATM存取款系統(tǒng)實(shí)現(xiàn)源碼
這篇文章主要為大家介紹了C語(yǔ)言編程銀行ATM存取款系統(tǒng)實(shí)現(xiàn)的源碼示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2021-11-11