c语言菜单函数字母选项,c语言菜单函数字母选项在哪-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

c语言菜单函数字母选项,c语言菜单函数字母选项在哪

C语言菜单选项程序?

改一下试试:

创新互联建站为您提适合企业的网站设计 让您的网站在搜索引擎具有高度排名,让您的网站具备超强的网络竞争力!结合企业自身,进行网站设计及把握,最后结合企业文化和具体宗旨等,才能创作出一份性化解决方案。从网站策划到网站设计制作、网站设计, 我们的网页设计师为您提供的解决方案。

int main() {

void zhi(void);

void han(void);

void shu(void);

void fen(int x);

void xun(int x);

char chose,s[20];

int n;

for(;;) {

printf("1:分支程序\n2:循环程序\n3:函数程序\n4:数组程序\n5:指针程序\n0:退出\n\n选择数字:");

scanf("%s",s); chose=s[0];

switch(chose) {

case'1':printf("这是个销售量与其相应等级的分支程序,请输入相应销售量!\n");

scanf("%d",n);

fen(n);

break;

case'2':printf("这是个求0——n累加之和的循环结构,输入n,下面为其值!\n");

scanf("%d",n);

xun(n);

break;

case'3':printf("这是一个求最大公约数的函数程序,请输入两个数的值!\n");

han();

break;

case'4':printf("这是一个数组逆行排序的数组程序,请输入10个整数!\n");

shu();

break;

case'5':printf("这是一个用指针求一个三个数的数组和的指针程序,请输入这三个数!\n");

zhi();

break;

case'0':exit(1);

default:break;

}

}

return 0;

}

求一个C语言菜单函数的程序?

1、对于窗口组件菜单,需要根据不同平台,通过图形编程接口,进行菜单的编制。

例程:

#includestdio.h 

#includegraphics.h 

#includeconio.h 

void main() 

char str; 

int i,k,choice=1; 

int gd=DETECT,gm; 

initgraph(gd,gm," "); 

setbkcolor(2); 

settextstyle(3,0,3); 

outtextxy(140,120,"A. The Mock Clock."); 

outtextxy(140,150,"B. The Digital Clock."); 

outtextxy(140,180,"C. Exit."); 

setlinestyle(0,0,3); 

rectangle(170,115,370,145); 

/*按上下键选择所需选项*/ 

for(i=1;i=100;i++) 

str=getch(); 

if(str==72) 

--choice; 

if(choice==0)choice=3; 

if(str==80) 

++choice; 

if(choice==4)choice=1; 

if(str==13)break; /*按回车键确认*/ 

/*画图做菜单*/ 

cleardevice(); 

switch(choice) 

{ case 1: setlinestyle(0,0,3); 

rectangle(170,115,400,145); 

settextstyle(3,0,3); 

outtextxy(140,120,"A. The Mock Clock."); 

settextstyle(3,0,3); 

outtextxy(140,150,"B. The Digital Clock."); 

outtextxy(140,180,"C. Exit."); 

break; 

case 2: setlinestyle(0,0,3); 

rectangle(170,145,400,175); 

settextstyle(3,0,3); 

outtextxy(140,120,"A. The Mock Clock."); 

settextstyle(3,0,3); 

outtextxy(140,150,"B. The Digital Clock."); 

settextstyle(3,0,3); 

outtextxy(140,180,"C. Exit."); 

break; 

case 3: settextstyle(3,0,3); 

outtextxy(140,120,"A. The Mock Clock."); 

outtextxy(140,150,"B. The Digital Clock."); 

settextstyle(3,0,3); 

outtextxy(140,180,"C. Exit."); 

setlinestyle(0,0,3); 

rectangle(170,175,400,205); 

break; 

if(i=100)exit(0);/*如果按键超过100次退出*/ 

switch(choice)/*这里引用函数,实现所要的功能*/ 

case 1: cleardevice(); 

setbkcolor(4); 

settextstyle(3,0,4); 

outtextxy(160,120,"No.1 have not built."); break; 

case 2: cleardevice(); 

setbkcolor(4); 

settextstyle(3,0,4); 

outtextxy(160,150,"No.2 have not built."); 

break; 

case 3: exit(0); 

getch(); 

closegraph(); 

}

2、对于命令行菜单,直接通过不断刷新输出来模拟菜单行为。

例程:

#include stdio.h

#include stdlib.h 

#include string.h

int n,t,k;

int m;

char s1[20],s2[20],c;

char **l;

char *num[]={"one","two","three","four","five","six","seven","eight","nine","ten"};

void menu()

{

printf("\n\n\t\t*******************************************************\n");

printf("\t\t**   1.查找字符串S1中S2出现的次数                    **\n");

printf("\t\t**   2.统计字符串中大小写字母,数字出现的次数        **\n");

printf("\t\t**   3.将数字翻译成英语                              **\n");

printf("\t\t**   4.结束                                          **\n");

printf("\t\t*******************************************************\n");

printf("\t\t     您的输入:");

fflush(stdin);

scanf("%d",n);

}

void check()

{

char a[20],b[20];

int j=0,k,m,l=0;

int t=0,n=0;

printf("请输入主字符串:\n");

scanf("%s",a);

k=strlen(a);

printf("请输入子字符串:\n");

scanf("%s",b);

m=strlen(b);

for(n=0;nk;n++)

if(a[n]==b[0])

{

j++; /*记录相同的字符数*/

do

{    

if(a[++n]==b[++t])

j++;

if(j==m) 

{

l++;/*子字符串相同数*/

j=0;/*判断后相同字符数归零*/

t=-1;/*判断中if中++t;t将会归零*/

}

}

else

{

j=0;

t=0;

break;/*如果不同跳出while循环让for使n+1继续判断*/

}

}while(a[n]!='\0');/*查找完字符数组a结束*/

}

printf("子字符串出现次数:\n%d\n",l);

}                                  

void cout()

{

int n=0,t=0,k=0;

printf("请输入一个字符串:\n");

fflush(stdin);/*清除缓冲*/

while((c=getchar())!='\n')

{

if(c='a'c='z')

n++;

if(c='A'c='Z')

t++;

if(c='0'c='9')

k++;

}

printf("有大写字母:\n%d\n",t);

printf("有小写字母:\n%d\n",n);

printf("有数字:\n%d\n",k);

}

void number()

{

l=num;

printf("请输入一个数字:(0-10)\n");

fflush(stdin);

scanf("%d",m);

printf("%d对应的英文是:\n%s\n",m,*(l+m-1));

}

void main()

{

while(1)

{   

system("cls");

menu();

switch(n)

{

case 1:system("cls");check();system("pause");break;

case 2:system("cls");cout();system("pause");break;

case 3:system("cls");number();system("pause");break;

case 4:system("cls");break;

default:system("cls");break; 

}

if(n==4) break;

}

printf("感谢使用\n");

}

C语言函数菜单的问题

//求长度

int Length(char* szSrc)

{ static int nCount=0;

while(*(szSrc+nCount)!='\0')

nCount++;

return nCount;

}

//有一个字符串,包含n个字符。写一函数,将此字符串从第m个字符开始的全部字符复制成另一个字符串。

char* Mid(char* szSrc,int n1,int n2)

{

static char sz[1024];

memset(sz,0,sizeof(sz));

strncpy(sz,szSrc+n1,n2-n1+1);

return sz;

}

//逆序 数字逆序要把长度也送进去

void changestr(char *szSrc)

{

static int nCount=0;

do(*(szSrc+nCount)!='\0')

nCount++;

for(int i=0; i=nCount/2;i++)

{

char ch;

ch =*(szSrc+i);

*(szSrc+i) = *(szSrc+nCount-i);

*(szSrc+nCount-i)=ch;

}

C语言中如何实现选项菜单的功能?

#includestdio.h

#include stdlib.h

void hello()

{

printf("hello world\n");

}

int main()

{

int x;

while (1)

{

printf("-------------操作选项-----------\n");

printf("1:返回菜单 \n");

printf("2:退出程序 \n");

printf("3:执行操作 \n");

printf("--------------------------------\n");

printf("按数字键选择要执行的操作: ");

scanf("%d",x);

printf("\n");

//输入2跳出循环,退出程序

if(x==2)

  break;

switch(x)

{

case 1:  break; //输入1,跳出switch语句,进入下一次循环

case 3:  hello();break;  

default:  //数字输入错误,跳出siwtch语句,进入下一次循环

  printf("输入的数字不正确\n");

  break;

}

}

return 0;

}

说明:有3个选项,1是用返回菜单,2是用于退出程序,3是用于执行相关的操作,这里只是一个示例,所以将要执行的操作,编写成了一个输出hello world的函数。

怎么写简单的C语言菜单?

1、使用输出函数即可。

2、例程:

#include iostream

#include stdlib.h

#include conio.h

#include ctype.h

using namespace std;

void xuanzepaixu()           //选择排序函数

{

printf("待添加,请按任意键继续...");

getchar();

}

void erfenpaixu()           //二分查找函数

{

printf("待添加,请按任意键继续...");

getchar();

}

void menu()    //主菜单

{

system("cls"); //清屏

printf("\n\t\t\t        菜单\n");

printf("\t\t\t#***********************#\n");

printf("\t\t\t#    1选择排序          #\n");

printf("\t\t\t#    2二分查找          #\n");

printf("\t\t\t#    3返回              #\n");

printf("\t\t\t#    4---关闭           #\n");

printf("\t\t\t#***********************#\n");

printf("\t\t\t      请选择(1-4) =:");

}

void main()

{

char select;

while(1)

{  

menu();

system("COLOR 9f");       

scanf("%c",select);

if(select=='3')

break;      //返回上级菜单

else

{

getchar(); //读入回车符

if(!isdigit(select)) //如果不是数字字符

{

printf("\n\7Your select may be wrong, must enter the digit!\n");_getch();

}

else

{

switch (select)

{

case '1': xuanzepaixu();break;

case '2': erfenpaixu();break;

case '4':exit(0);             //直接退出

default: 

{

printf("\n\7\7Your selected digit may be wrong, select again!\n");

_getch();

break;

}

}

}

}

};

}


网站名称:c语言菜单函数字母选项,c语言菜单函数字母选项在哪
文章URL:http://kswsj.cn/article/hsdoic.html

其他资讯