#include<stdio.h>
#include<stdio.h>
#include<string.h>
char choice;
void showtopmenu()
{
printf("1 add\n");
printf("2 update\n");
printf("3 delete\n");
printf("4 showall\n");
printf("5 showone\n");
printf("6 exit\n");
}
void process_add()
{
printf("process_add\n");
showtopmenu();
}
void process_update()
{
printf("process_update\n");
showtopmenu();
}
void process_delete()
{
printf("process_delete\n");
showtopmenu();
}
void process_showall()
{
printf("process_showall\n");
showtopmenu();
}
void process_showone()
{
printf("process_showone\n");
showtopmenu();
}
void process_exit()
{
exit(0);
}
main()
{
showtopmenu();
while(1)
{
choice = getchar();
switch(choice)
{
case '1': process_add();break;
case '2': process_update();break;
case '3': process_delete();break;
case '4': process_showall();break;
case '5': process_showone();break;
case '6': process_exit();break;
default : showtopmenu();
}
}
}
----------------解决方案--------------------------------------------------------
来学习的
顶上
----------------解决方案--------------------------------------------------------
#include<stdio.h>
#include<stdio.h>
#include<string.h>
void showtopmenu()
{
printf("1 add\n");
printf("2 update\n");
printf("3 delete\n");
printf("4 showall\n");
printf("5 showone\n");
printf("6 exit\n");
}
void process_add()
{
printf("process_add\n");
showtopmenu();
}
void process_update()
{
printf("process_update\n");
showtopmenu();
}
void process_delete()
{
printf("process_delete\n");
showtopmenu();
}
void process_showall()
{
printf("process_showall\n");
showtopmenu();
}
void process_showone()
{
printf("process_showone\n");
showtopmenu();
}
void process_exit()
{
exit(0);
}
main()
{ int choice;
showtopmenu();
while(1)
{
scanf("%d",&choice);
switch(choice)
{
case 1: process_add();break;
case 2: process_update();break;
case 3: process_delete();break;
case 4: process_showall();break;
case 5: process_showone();break;
case 6: process_exit();break;
default : showtopmenu();
}
}
}
----------------解决方案--------------------------------------------------------
我在测试的时候发现 如果是用字符型的话 WHILE是循环2次进行一次输入 所以老运行default
----------------解决方案--------------------------------------------------------
正解
----------------解决方案--------------------------------------------------------
mp3aaa就是叼
学习
----------------解决方案--------------------------------------------------------