c语言:编写一个菜单调用程序,调用前边编写的4个小程序

2024-10-31 06:12:46
推荐回答(1个)
回答1:


#include

#include

void chengxu1(){printf("chengxu1\n");};

void chengxu2(){printf("chengxu2\n");};

void chengxu3(){printf("chengxu3\n");};

void chengxu4(){printf("chengxu4\n");};

void display()

{

printf("输入1,2,3,4选择菜单\n");

printf("________________\n");

printf("1:chengxu1\n");

printf("2:chengxu2\n");

printf("3:chengxu3\n");

printf("4:chengxu4\n");

printf("________________\n");

printf("input a number:");

};

main(void)

{

while(1)

{

display();

switch(getchar())

{

case '1':chengxu1();break;

case '2':chengxu2();break;

case '3':chengxu3();break;

case '4':chengxu4();break;

default:printf("error!\n");

}

system("pause");

system("cls"); 

}


}