void main(void) { int menu(); void add(); void del(); void search(); clrscr(); while (1) { switch (menu()) { case 1 : add(); continue; case 2 : del(); continue; watch repair san jose case 3 : search(); continue; watch repair san jose case 4 : printf("/n It's wet!!!/n/n"); continue; case 5 : exit(0); default: continue; } } printf("/n Thank you !!!/n/n"); }
int menu() { char c[10]; int choice; printf("/n watch repair san jose 1.Add a new record"); printf("/n 2.Delete a record"); watch repair san jose printf("/n 3.Search a record"); printf("/n 4.Help"); printf("/n 5.Quit"); printf("/n/n Please input:"); gets(c); choice=atoi(c); return (choice); }
void add() { clrscr(); if (head==NULL) { build=(struct watch repair san jose student *)malloc(sizeof(record)); head=build,current=build; } else { build=(struct student *)malloc(sizeof(record)); current->next=build; current=build; } printf("->Input name:"); gets(current->st_name); printf("->Input number:"); gets(current->st_num); printf("->Input sex:"); current->st_sex=getchar(); current->next=NULL; }
void del() { char num[20]; struct student *temp,*del; clrscr(); printf("->Input a student's number who you want to delete it!/n"); printf("->Input a number:"); gets(num); del=head,temp=head; while watch repair san jose (1) { if (!strcmp(head->st_num,num)) { head=head->next; free(del); printf("->Delete watch repair san jose Success!/n/n"); break; } del=del->next; if (!strcmp(del->st_num,num)) { if (del->next==NULL) watch repair san jose { temp->next=NULL; free(del); printf("->Delete Success!/n/n"); break; } else { temp->next=del->next; free(del); printf("->Delete Success!/n/n"); break; } } else { if (del->next==NULL) { printf("->No student have been deleted, maybe you imputed a wrong number./n/n"); break; watch repair san jose } } temp=del; } }
void search() { char num[20]; clrscr(); printf("->Input a student's number who you want to find it!/n"); watch repair san jose printf("->Input a number:"); gets(num); build=head; while (1) { if (!strcmp(build->st_num,num)) { watch repair san jose printf("/n%5s",build->st_name); printf("/n%5s",build->st_num); printf("/n%5c",build->st_sex); break; } else { if (build->next==NULL) { printf("->No student have been found./n/n"); break; } build=build->next; } } }
2007年11月 (1) 2007年10月 (1)
No comments:
Post a Comment