欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

c語言菜單函數(shù)的功能,c語言主菜單函數(shù)

怎樣用C語言編寫菜單

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

我們提供的服務(wù)有:網(wǎng)站建設(shè)、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、徐州ssl等。為上千企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的徐州網(wǎng)站制作公司

例程:

#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;?/*按回車鍵確認(rèn)*/?

/*畫圖做菜單*/?

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語言中怎么編制簡單的菜單,通過菜單選擇能實現(xiàn)程序的各項功能

#include iostream

#include stdlib.h

#include conio.h

#include ctype.h

using namespace std;

void xuanzepaixu() //選擇排序函數(shù)

{

printf("待添加,請按任意鍵繼續(xù)...");

getchar();

}

void erfenpaixu() //二分查找函數(shù)

{

printf("待添加,請按任意鍵繼續(xù)...");

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---關(guān)閉 #\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)) //如果不是數(shù)字字符

{

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語言中函數(shù)的作用

C語言中的函數(shù)的作用是可以將一段經(jīng)常需要使用的代碼封裝起來,在需要使用時可以直接調(diào)用。

示例:

語言的函數(shù)定義和函數(shù)聲明

#includestdio.h

//使用函數(shù)前,需要在main函數(shù)前對使用的函數(shù)進(jìn)行聲明

int getMax(int, int);

void main() {

int t=getMax(12, 21);

printf("%d\n", t);

getchar();

}

int getMax(int a, int b) {

if (a b) {

return a;

}

else {

return b;

}

}

擴(kuò)展資料

scanf 函數(shù)

函數(shù)原型:int scanf(char *format [,argument,...])

功能:從標(biāo)準(zhǔn)輸入設(shè)備(一般指鍵盤)實現(xiàn)格式化輸入

返回值:成功返回讀入的數(shù)據(jù)項個數(shù)

函數(shù)參數(shù):format 格式化字符串

argument 輸入數(shù)據(jù)項的地址列表

常用格式類型參考printf函數(shù)的個格式類型

用法舉例:

從標(biāo)準(zhǔn)輸入設(shè)備中輸入一個整數(shù)到整形變量a中,輸入一個浮點數(shù)到浮點型變量b中

int a=0;

float b=0;

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

上面程序執(zhí)行后,從鍵盤輸入: 19 18.6 ,程序?qū)?19賦值給變量a, 18.6賦值給變量b 。

C語言菜單設(shè)計及功能調(diào)用

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

#includestdio.h

#includewindows.h

//\n1.增加 2.查詢 3.刪除 4.退出\n");

//聲明函數(shù)

void addnd();

void searchnd();

void printnd();

void charund();

//含 枚舉類型 分支switch

enum mmenu{/*定義一個名為mmenu的枚舉類型

可以讓常量有一定的含義(如實現(xiàn)菜單)*/

addn=1,//默認(rèn)是0,定義為1后 后面的成員也會自動變換(排序)

searchn,

printn,

quitn

};

void main(){

enum mmenu input;

while(1){

printf("菜單\n1.增加 2.查詢 3.打印 4.退出\n");

scanf("%d",input);

Sleep(500);

system("cls");

switch(input){//case內(nèi)的情況 只能是整型或字符型的常量

case addn:printf("選中了1.增加\n");addnd();break;

case searchn:printf("選中了2.查詢\n");searchnd();break;

case printn:printf("選中了3.打印\n");printnd();break;

case quitn:printf("選中了4.退出\n");exit(0);break;

default :printf("不在選項內(nèi),請重新輸入!\n");break;}

};

}

void addnd(){//增加

printf("http://請自定義addnd()函數(shù)代碼//\n");

}

void searchnd(){

printf("http://請自定義searchnd()函數(shù)代碼//\n");

}

void printnd(){//打印

printf("http://請自定義printnd()函數(shù)代碼//\n");

}

void charund(){

printf("http://請自定義charund函數(shù)代碼//\n");

}

C語言中如何實現(xiàn)選項菜單的功能?

#include process.h

#include dos.h

#include conio.h

#define Key_DOWN 0x5100

#define Key_UP 0x4900

#define Key_ESC 0x011b

#define Key_ALT_F 0x2100

#define Key_ALT_X 0x2d00

#define Key_ENTER 0x1c0d

void box(int startx,int starty,int high,int width);

main()

{

int i,key,x,y,l;

char *menu[] = {"File","Edit","Run","Option","Help","Setup","Zoom","Menu"};

char *red[] = { "F","E","R","O","H","S","Z","M" };

char *f[] = {"Load file", "Save file", "Print", "Modify ", "Quit A1t_x"};

char buf[16*10*2],buf1[16*2];

while(1)

{

textbackground(BLUE);

clrscr();

textmode(C80);

window(1,1,80,1);

textbackground(LIGHTGRAY);

textcolor(BLACK);

clrscr();

gotoxy(5,1);

for(i=0,l=0;i8;i++)

{

x=wherex();

y=wherey();

cprintf("%s",menu[i]);

l=strlen(menu[i]);

gotoxy(x,y);

textcolor(RED);

cprintf("%s",red[i]);

x=x+l+5;

gotoxy(x,y);

textcolor(BLACK);

}

gotoxy(5,1);

key=bioskey(0);

switch (key){

case Key_ALT_X:

exit(0);

case Key_ALT_F:

{

textbackground(BLACK);

textcolor(WHITE);

gotoxy(5,1);

cprintf("%s",menu[0]);

gettext(5,2,20,12,buf);

window(5,2,20,9);

textbackground(LIGHTGRAY);

textcolor(BLACK);

clrscr();

box(1,1,7,16);

for(i=2;i7;i++)

{ gotoxy(2,i);

cprintf("%s",f[i-2]);

}

gettext(2,2,18,3,buf1);

textbackground(BLACK);

textcolor(WHITE);

gotoxy(2,2);

cprintf("%s",f[0]);

gotoxy(2,2);

y=2;

while ((key=bioskey(0))!=Key_ALT_X)

{

if ((key==Key_UP)||(key==Key_DOWN))

{

puttext(2,y,18,y+1,buf1);

if (key==Key_UP)

y=y==2?6:y-1;

else

y=y==6?2:y+1;

gettext(2,y,18,y+1,buf1);

textbackground(BLACK);

textcolor(WHITE);

gotoxy(2,y);

cprintf("%s",f[y-2]);

gotoxy(2,y);

}

else

if (key==Key_ENTER)

{

switch ( y-1 ){

case 1:

break;

case 2:

break;

case 3:

break;

case 4:

break;

case 5:

exit(0);

default:

break;

}

break;

}

else

if (key==Key_ESC)

break;

}

if (key==Key_ALT_X) exit(0);

break;

}

}

}

}

void box(int startx,int starty,int high,int width)

{ int i;

gotoxy(startx,starty);

putch(0xda);

for (i=startx+1;iwidth;i++) putch(0xc4);

putch(0xbf);

for( i=starty+1;ihigh;i++)

{

gotoxy(startx,i);putch(0xb3);

gotoxy(width,i);putch(0xb3);

}

gotoxy(startx,high);

putch(0xc0);

for (i=startx+1;iwidth;i++) putch(0xc4);

putch(0xd9);

return ;

}

當(dāng)前文章:c語言菜單函數(shù)的功能,c語言主菜單函數(shù)
文章路徑:http://chinadenli.net/article4/dsgdpie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作云服務(wù)器品牌網(wǎng)站建設(shè)標(biāo)簽優(yōu)化自適應(yīng)網(wǎng)站面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司