真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

c語言函數(shù)編菜單 c語言編寫菜單函數(shù)

怎樣用C語言編寫菜單

對于窗口組件菜單,需要根據(jù)不同平臺,通過圖形編程接口,進行菜單的編制。

創(chuàng)新互聯(lián)建站主要從事網(wǎng)站制作、成都網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)和縣,十年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792

例程:

#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)/*這里引用函數(shù),實現(xiàn)所要的功能*/?

{?

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();?

}

對于命令行菜單,直接通過不斷刷新輸出來模擬菜單行為。

例程:

#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出現(xiàn)的次數(shù)????????????????????**\n");

printf("\t\t**???2.統(tǒng)計字符串中大小寫字母,數(shù)字出現(xiàn)的次數(shù)????????**\n");

printf("\t\t**???3.將數(shù)字翻譯成英語??????????????????????????????**\n");

printf("\t\t**???4.結(jié)束??????????????????????????????????????????**\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++;?/*記錄相同的字符數(shù)*/

do

{????

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

{?

j++;

if(j==m)?

{

l++;/*子字符串相同數(shù)*/

j=0;/*判斷后相同字符數(shù)歸零*/

t=-1;/*判斷中if中++t;t將會歸零*/

}

}

else

{

j=0;

t=0;

break;/*如果不同跳出while循環(huán)讓for使n+1繼續(xù)判斷*/

}

}while(a[n]!='\0');/*查找完字符數(shù)組a結(jié)束*/

}

printf("子字符串出現(xiàn)次數(shù):\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("有數(shù)字:\n%d\n",k);

}

void?number()

{

l=num;

printf("請輸入一個數(shù)字:(0-10)\n");

fflush(stdin);

scanf("%d",m);

printf("%d對應(yīng)的英文是:\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語言編程做一個簡單的菜單

#include?stdio.h

#include?stdlib.h

void?menu()????????//菜單繪制

{

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

printf("\t\t?0.退出\n");

printf("\t\t?1.錄入信息\n");

printf("\t\t?2.查找信息\n");

printf("\t\t?3.刪除信息\n");

printf("\t\t?4.瀏覽信息\n");

printf("\t\t??5.有其他疑問找群主")

printf("\t\t??6.C++8群:?491994603")

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

}

void?keyDown()????//按鍵處理

{

int?choice;

scanf("%d",?choice);

switch?(choice)

{

case?0:

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

Sleep(2000);

return?0;

case?1:

//調(diào)用菜單1實現(xiàn)函數(shù)

break;

case?2:

//調(diào)用菜單2實現(xiàn)函數(shù)

break;

case?3:

//調(diào)用菜單3實現(xiàn)函數(shù)

break;

case?4:

//調(diào)用菜單4實現(xiàn)函數(shù)

break;

default:

printf("輸入錯誤\n");

}

system("pause");

return?0;

}

int?main()

{

while(1)????????

{

menu();

keyDown();

system("cls");

}

return?0;

}

C語言編寫菜單

#includestdio.h?

#includestring.h?

#includestdlib.h

//值傳遞

void?fun1(char?a)

{

a?=?'b';

}

//地址傳遞

char?fun2(char*?a)

{

*a?=?'a';

return?*a;

}

//動態(tài)分配數(shù)組

void?fun3(char*?a)

{

a??=?(char*)malloc(sizeof(char));

}

char?caidan()?

{?

char?choose[5];?

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

printf("??????┌──────┐\n");?

printf("??????│?菜單│\n");?

printf("?__________________________________\n");?

printf("│?1,按值傳遞????|\n");?

printf("│?2,按地址傳遞??|\n");?

printf("│?3,動態(tài)數(shù)組演示|\n");?

printf("│?4,退?出???????|\n");?

printf("└────────────────┙\n");?

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

do?

{?

printf("請輸入您的選擇(1-4):");?

scanf("%s",choose);?

}while(strcmp(choose,"1")strcmp(choose,"2")strcmp(choose,"3")strcmp(choose,"4"));?

//返回選擇的菜單,注意如果輸入太長?這里會異常,因為choose[5],只申請了5個字節(jié)。?

return?choose[0];?

}?

void?main()

{

//執(zhí)行菜單的選擇?

while(1)

{

switch(caidan())?

{?

case?'1':

{

char?a?=?'a';

fun1(a);

//按值傳遞?內(nèi)容不變

break;?

}

case?'2':

{

char?b?=?'b';

char?a?=?fun2(b);

//按地址傳遞內(nèi)容會變

break;?

}

case?'3':

{

char*?p?=?NULL;

fun3(p);

//動態(tài)數(shù)組分配成功

break;?

}

case?'4':exit(0);?

}?

}

}

怎么用C語言編寫菜單?

#include "stdio.h"

#include "stdlib.h"

#include "dos.h"

#include "windows.h"

char choice1;

void main()

{

void menue1();

printf("歡迎進入Ben的作業(yè)查詢系統(tǒng)!");

menue1();

}

void menue1()

{

void choicemenue1();

printf("\n請按照以下列表選擇您想要查看的章節(jié):");

printf("\n編號\t章節(jié)\n 1\t第一章\n 2\t第二章\n");

printf("請輸入編號進行選擇:");

choicemenue1();

}

void choicemenue1()

{

choice1=getch();

switch(choice1)

{

void menuechapter1();

void menuechapter2();

void menue1();

case '1':menuechapter1();break;

case '2':menuechapter2();break;

default:printf("\n輸入錯誤!請重新選擇!\n"),menue1();

}}

void menuechapter1()

{

char choiceex;

printf("\n您選擇的是第%c章",choice1);

printf("\n現(xiàn)在請選擇本章節(jié)的題目。");

printf("\n請按照以下列表選擇題目:");

printf("\n編號\t題目編號\n1\t第1題\n2\t第2題\n");

printf("請選擇:");

switch(choiceex=getch())

{

void c1_1();

void c1_2();

case '1':c1_1();break;

case '2':c1_2();break;

default:

printf("\n你個白癡!這也能選錯!不讓你重選了!");

printf("\n按任意鍵以退出!");

getch();

exit(0);

}

}

void menuechapter2()

{

char choiceex;

printf("\n您選擇的是第%c章",choice1);

printf("\n現(xiàn)在請選擇本章節(jié)的題目。");

printf("\n請按照以下列表選擇題目:");

printf("\n編號\t題目編號\n1\t第1題\n2\t第2題\n");

printf("\n請選擇:");

switch(choiceex=getch())

{

void c2_1();

void c2_2();

case '1':c2_1();break;

case '2':c2_2();break;

default:

printf("\n你個白癡!這也能選錯!不讓你重選了!");

printf("\n按任意鍵以退出!");

getch();

exit(0);

}

}

void c1_1()

{

char howtorun;

printf("現(xiàn)在請選擇考察方式:");

printf("\n編號\t考察方式\n 1\t運行程序\n 2\t查看源代碼\n 3\t返回主菜單\n 4\t退出程序\n");

printf("請選擇:");

switch(howtorun=getch())

{

void runc1_1();

void menue1();

case '1':runc1_1();break;

case '2':printf("\n"),system("type \\caidan\\chapter1\\c1_1.c"),printf("\n"),getch();break;

case '3':menue1();break;

case '4':exit(0);break;

default:

printf("程序即將結(jié)束!哈哈哈……");

printf("按任意鍵以結(jié)束程序!");

getch();

exit(0);

}}

void c1_2()

{

printf("c1_2 is OK!");

}void c2_1()

{

printf("c2_1 is OK!");

}void c2_2()

{

printf("c2_2 is OK!");

}

void runc1_1()

{

int a,b,max;

printf("\nPlease input two integer numbers:");

printf("a=?,b=?\n");

scanf("%d,%d",a,b);

max=ab?a:b;

printf("The max number is %d",max);

}

大概就是這樣做的。。


分享標題:c語言函數(shù)編菜單 c語言編寫菜單函數(shù)
URL分享:http://weahome.cn/article/hhjspp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部