user-0 提问: 求助 怎末简化这个程序

回复:
user: user-0
content: 谢谢老师，

user: user-1
content: #include <stdio.h> #include <stdlib.h> #include <string.h> #define  MAX_people  30 char names     [MAX_people][50]; int  sex       [MAX_people]; int  time      [MAX_people]; int  num       [MAX_people]; int  temp_num  [MAX_people]; char temp_names[MAX_people][50]; int  temp_time [MAX_people]; int  temp_sex  [MAX_people]; int  sort      [MAX_people]; int i, j; void people_scanf(int n) {     for (i = 0; i<n; ++i) {         printf("\n请输入第%d个顾客的信息:\n", i + 1);         printf("\n身份证号:"); scanf("%d", &num[i]);         printf("\n姓名:");     scanf("%s", names[i]);         printf("\n性别:");     scanf("%d", &sex[i]);         printf("\n入住时间:"); scanf("%d", &time[i]);     } } void people_printf(int n) {     printf("\n身份证号\t姓名\t入住时间\t性别\n");     printf("-------------------------------------------------------\n");     for (i = 0; i<n; ++i) {         printf("%d\t%s\t%d\t%d\n", num[i], names[i], sex[i], time[i]);     }     printf("-------------------------------------------------------\n"); } int people_find_num(int n) {     int nums;     int result;      printf("请输入待查找的顾客身份证号:");     scanf("%d",&nums);     result= -1;     for (i = 0; i<n; ++i) {         if (nums == num[i]) {             result = i;             break;         }     }     if (result == -1) {         printf("没有该顾客信息!\n");         return 0;     } else {         printf("\n身份证号\t姓名\t入住时间\t性别\n");         printf("%d\t%s\t%d\t%d\t", num[result], names[result], time[result], sex[result]);         printf("打印出查找结果!\n");     }     return 1; } int people_find_name(int n) {     char name[200];     int result;      printf("请输入待查找的顾客姓名:");     scanf("%s", name);     result = -1;     for (i = 0; i<n; ++i) {         if (strcmp(name, names[i]) == 0) {             result = i;             break;         }     }     if (result == -1) {         printf("没有该顾客信息!\n");         return 0;     } else {         printf("\n身份证号\t姓名\t入住时间\t性别\n");         printf("%d\t%s\t%d\t%d\t", num[result], names[result], time[result], sex[result]);         printf("已完成查找!\n");     }     return 1; } int people_alter_name(int n) {     char name[50];     int result;      printf("请输入待修改的顾客姓名:");     scanf("%s",name);     result= -1;     for (i = 0; i<n; ++i) {         if (strcmp(name,names[i])==0) {             result = i;             break;         }     }     if (result == -1) {         printf("没有该顾客信息!\n");         return 0;     } else {         printf("请重新输入该顾客信息：\n");         printf("身份证号："); scanf("%d",&num[result]);         printf("姓名：");     scanf("%s",names[result]);         printf("入住时间："); scanf("%d",&time[result]);         printf("性别：");     scanf("%d",&sex[result]);     }     return 1; } int people_delete_name(int n) {     char name[50];     int result;      printf("请输入待删除的顾客姓名:");     scanf("%s",name);     result= -1;     for (i = 0; i<n; ++i) {         if (strcmp(name,names[i])==0) {             result = i;             break;         }     }     if (result == -1) {         printf("没有该顾客信息!\n");         return 0;     } else {         for(i=result; i<n-1; ++i) {             num[i] = num[i+1];             strcpy(names[i],names[i+1]);             time[i] = time[i+1];             sex[i] = sex[i+1];         }     }     return 1; } int main() {     int choice,n;     while (1) {         printf("*************************************\n"                "欢迎使用酒店信息管理系统\n"                "[1] 输入所有顾客信息\n"                "[2] 按姓名查找某个顾客信息\n"                "[3] 按姓名修改某个顾客信息\n"                "[4] 按姓名删除某个顾客信息\n"                "[0] 退出程序\n"                "请输入您的选择（0 - 4）:");         rewind(stdin);         scanf("%d",&choice);         printf("**************************************)\n");         if (0==choice) {             printf("程序结束，谢谢使用!\n");             break;         }         switch (choice) {         case 1:             printf("请输入录入的顾客信息数： ");             scanf("%d",&n);             people_scanf(n);             break;         case 2:             people_find_name(n);             break;         case 3:             people_alter_name(n);             break;         case 4:             people_delete_name(n);             n--;             break;         default:             printf("您输入的菜单有误。请重新输入！\n");         }     }     return 0; }