當前位置:首頁 » 編程軟體 » 菜單編程

菜單編程

發布時間: 2022-07-15 00:37:33

Ⅰ 跪求 使用C語言生成下拉菜單的編程

下拉菜單?用C來做?
可以的,這是c的高級應用。代碼嘛可能超過1000行。推薦看這本書,很不錯的,網上有清晰的電子版:
C高級實用程序設計(王仕元 編著 清華大學出版社)

Ⅱ 求C++編程題目【菜單】計算機菜單中有N個操作,而每個操作都會用一個或更多的單詞來描述。

#include<iostream>	//cin,cout,cerr
#include<cctype> //toupper
#include<string> //string
#include<vector> //vector
#include<sstream> //stringstream
#include<fstream> //ifstream,ofstream
usingnamespacestd;

boolletterExist[26]={false}; //用於查詢快捷鍵(即字母)是否存在的標志
vector<vector<string>>menuVec; //存儲所有菜單信息的二維向量(類似於二維數組)
conststringinputFile="./izbornik.in";
conststringoutputFile="./izbornik.out";

intinput()
{
ifstreamread(inputFile,ios::in);
if(!read)
{
cerr<<"[READ]Openfileerror!"<<endl;
return-1;
}
stringmenu;
while(getline(read,menu)) //從文件讀取菜單信息(一行,包括空格)
{
//拆分一行的菜單,形成菜單的單詞向量(數組)
stringstreamss;
ss<<menu;
stringword;
vector<string>wordVec;
while(ss>>word)
wordVec.push_back(word);
//
menuVec.push_back(wordVec);
}
read.close();
return0;
}

voidprocess()
{
//初始化標志
for(inti=0;i<26;++i)
letterExist[i]=false;
//處理每個菜單
for(inti=0;i<menuVec.size();++i)
{
boolisFind=false;
//step1:首先找同一菜單每個單詞的首字母
//[0]所有單詞首字母
for(intj=0;j<menuVec[i].size();++j)
{
intindex=toupper(menuVec[i][j][0])-'A';
//cout<<i<<"|"<<j<<"|"<<"0"<<endl;
if(!letterExist[index])
{
//
stringheadStr;
headStr+='[';
headStr+=menuVec[i][j][0];
headStr+=']';
menuVec[i][j]=headStr+
menuVec[i][j].substr(1,menuVec[i][j].size()-1);
//
letterExist[index]=true;
isFind=true;
break;
}
}
//![0]
//step2:讓後從剩下的所有單詞字母中找
//[1]除去首字母之外後的所有字母
if(!isFind)
{
for(intj=0;j<menuVec[i].size();++j)
{
for(intk=1;k<menuVec[i][j].size();++k)
{
intindex=toupper(menuVec[i][j][k])-'A';
//cout<<i<<"|"<<j<<"|"<<k<<endl;
if(!letterExist[index])
{
//
stringheadStr;
headStr+=menuVec[i][j].substr(0,k);
headStr+='[';
headStr+=menuVec[i][j][k];
headStr+=']';
menuVec[i][j]=headStr+
menuVec[i][j].substr(k+1,menuVec[i][j].size()-k-1);
//
letterExist[index]=true;
isFind=true;
break;
}
}
if(isFind)
break;
}
}
//![1]
}
}

intoutput()
{
ofstreamwrite(outputFile,ios::out);
if(!write)
{
cerr<<"[WRITE]Openfileerror!"<<endl;
return-1;
}
for(inti=0;i<menuVec.size();++i)
{
intj;
for(j=0;j<menuVec[i].size()-1;++j)
{
write<<menuVec[i][j]<<"";
}
write<<menuVec[i][j]<<endl;
}
write.close();
return0;
}

intmenu_main()
{
if(input()==0)
{
process();
if(output()==0)
{
cout<<"Allprocessdone!"<<endl;
return0;
}
else
return-1;
}
else
{
return-1;
}
}

備註:

輸入文件放在當前目錄下(和main文件同級),文件只存放菜單內容,如:

New
Open
Save
Save As
Save All

其他格式可按照題目要求改~

Ⅲ 如何用HTML編程實現下拉菜單

下拉菜單,其實就是使用HTML+css和一些小小的js就能很簡單的實現,

  1. 首先需要你有至少有2個div然後在將第一個div作為父級元素,然後在使用position:absolut;絕對定位一下;

  2. 然後在使用JS,獲取對象,然後添加一個滑鼠的onmouseover事件就行了

  3. 在這里給你看下我以前的寫的一個代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>簡潔實用的二級下拉導航菜單</title>

<meta http-equiv="content-type" content="text/html;charset=gb2312">

<!--把下面代碼加到<head>與</head>之間-->

<style type="text/css">

body,html{padding:0;margin:0;text-align:center;font:normal 14px 'arial';}

#mainNavBar{width:100%;background:#999;padding:10px 0;}

#nav{width:760px;height:30px;margin:0 auto;}

#nav ul{padding:0;margin:0;}

#nav ul li{position:relative;float:left;width:60px;height:30px;line-height:30px;overflow:hidden;list-style-type:none;}

#nav ul li a{display:block;color:#fff;text-decoration:none;}

#nav ul li a:hover{font-weight:bold;background:#666;}

#subNav{position:absolute;width:150px;top:30px;left:0px;padding:5px;background:#666;color:#fff;text-align:left;}

#subNav a{text-decoration:none;font-weight:normal;display:block;}

#subNav a:hover{color:#f00;background:#f00;}

</style>

</head>

<body>

<!--把下面代碼加到<body>與</body>之間-->

<div id="mainNavBar">

<div id="nav">

<ul>

<li>

<a href="#">Add</a>

<div id="subNav">

<a href="#">寫日誌</a>

<a href="#">增加分類</a>

</div>

</li>

<li>

<a href="#">Edit</a>

<div id="subNav">

<a href="#">修改分類</a>

<a href="#">文章編輯</a>

</div>

</li>

<li>

<a href="#">Admin</a>

<div id="subNav">

<a href="#">文章管理</a>

<a href="#">評論管理</a>

<a href="#">留言管理</a>

<a href="#">退出</a>

</div>

</li>

</ul>

</div>

</div>

<script language="javascript">

var nav=document.getElementById("nav").getElementsByTagName("li");

for(i=0;i<nav.length;i++){

nav[i].onmouseover=function(){

this.style.fontWeight="bold";

this.style.overflow="visible";

this.style.background="#666666";

}

nav[i].onmouseout=function(){

this.style.fontWeight="normal";

this.style.background="#999999"

this.style.overflow="hidden";

}

}

</script>

</body>

</html>




#header #shousuo{

width:950px;

height:50px;

background:#f4f4f4;

margin-top:10px;

}


#shousuo ul li{

line-height:50px;

list-style-type:none;

float:left;

margin-left:5px;

font-weight:bold;

font-size:14px;

}

Ⅳ Excel 如何編程自定義多級菜單

「EXCEL中實現多級聯動的 下拉菜單 」的操作步驟是:1、以Excel 2016為例,打開Excel 工作表 ;2、在F:H列以一級菜單為標題,二級菜單縱向排列的方式建表;3、選擇一級菜單設置區域,在「數據」選項下的「 數據驗證 」(Exce 2007以下版本的「 數據有效性 」)中,「設置」選項選擇「序列」,來源選擇F1:H1單元格,確定;
4、選擇F:H列,在「公式」選項下的「根據所選內容創建」,在「選定區域創建名稱」對話框中,勾選「首行」,按「確定」,完成創建名稱;
5、選擇二級菜單設置區域,在「數據」選項下的「 數據有效性 」中,「設置」選項選擇「序列」,來源輸入=INDIRECT(A2) 確定;
6、在一級菜單設置區域,點擊下拉選項按鈕,選擇相應的菜單內容;
7、在二級菜單設置區域,點擊選項按鈕,會彈出與一級菜單相對應的二級菜單,供選擇。

Ⅳ 怎樣用C語言編寫菜單

  1. 對於窗口組件菜單,需要根據不同平台,通過圖形編程介面,進行菜單的編制。

    常式:

    #include<stdio.h>
    #include<graphics.h>
    #include<conio.h>
    voidmain()
    {
    charstr;
    inti,k,choice=1;
    intgd=DETECT,gm;
    initgraph(&gd,&gm,"");
    setbkcolor(2);
    settextstyle(3,0,3);
    outtextxy(140,120,"A.TheMockClock.");
    outtextxy(140,150,"B.TheDigitalClock.");
    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)
    {case1:setlinestyle(0,0,3);
    rectangle(170,115,400,145);
    settextstyle(3,0,3);
    outtextxy(140,120,"A.TheMockClock.");
    settextstyle(3,0,3);
    outtextxy(140,150,"B.TheDigitalClock.");
    outtextxy(140,180,"C.Exit.");
    break;
    case2:setlinestyle(0,0,3);
    rectangle(170,145,400,175);
    settextstyle(3,0,3);
    outtextxy(140,120,"A.TheMockClock.");
    settextstyle(3,0,3);
    outtextxy(140,150,"B.TheDigitalClock.");
    settextstyle(3,0,3);
    outtextxy(140,180,"C.Exit.");
    break;
    case3:settextstyle(3,0,3);
    outtextxy(140,120,"A.TheMockClock.");
    outtextxy(140,150,"B.TheDigitalClock.");
    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)/*這里引用函數,實現所要的功能*/
    {
    case1:cleardevice();
    setbkcolor(4);
    settextstyle(3,0,4);
    outtextxy(160,120,"No.1havenotbuilt.");break;
    case2:cleardevice();
    setbkcolor(4);
    settextstyle(3,0,4);
    outtextxy(160,150,"No.2havenotbuilt.");
    break;
    case3:exit(0);
    }
    getch();
    closegraph();
    }
  2. 對於命令行菜單,直接通過不斷刷新輸出來模擬菜單行為。

    常式:

    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    intn,t,k;
    intm;
    chars1[20],s2[20],c;
    char**l;
    char*num[]={"one","two","three","four","five","six","seven","eight","nine","ten"};
    voidmenu()
    {
    printf(" ******************************************************* ");
    printf(" **1.查找字元串S1中S2出現的次數** ");
    printf(" **2.統計字元串中大小寫字母,數字出現的次數** ");
    printf(" **3.將數字翻譯成英語** ");
    printf(" **4.結束** ");
    printf(" ******************************************************* ");
    printf(" 您的輸入:");
    fflush(stdin);
    scanf("%d",&n);
    }
    voidcheck()
    {

    chara[20],b[20];
    intj=0,k,m,l=0;
    intt=0,n=0;
    printf("請輸入主字元串: ");
    scanf("%s",a);
    k=strlen(a);
    printf("請輸入子字元串: ");
    scanf("%s",b);
    m=strlen(b);
    for(n=0;n<k;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]!='');/*查找完字元數組a結束*/
    }
    printf("子字元串出現次數: %d ",l);
    }
    voidcout()
    {
    intn=0,t=0,k=0;
    printf("請輸入一個字元串: ");
    fflush(stdin);/*清除緩沖*/
    while((c=getchar())!=' ')
    {
    if(c>='a'&&c<='z')
    n++;
    if(c>='A'&&c<='Z')
    t++;
    if(c>='0'&&c<='9')
    k++;
    }
    printf("有大寫字母: %d ",t);
    printf("有小寫字母: %d ",n);
    printf("有數字: %d ",k);
    }
    voidnumber()
    {
    l=num;
    printf("請輸入一個數字:(0-10) ");
    fflush(stdin);
    scanf("%d",&m);
    printf("%d對應的英文是: %s ",m,*(l+m-1));
    }
    voidmain()
    {
    while(1)
    {
    system("cls");
    menu();
    switch(n)
    {
    case1:system("cls");check();system("pause");break;
    case2:system("cls");cout();system("pause");break;
    case3:system("cls");number();system("pause");break;
    case4:system("cls");break;
    default:system("cls");break;
    }
    if(n==4)break;
    }
    printf("感謝使用 ");
    }

Ⅵ C語言 菜單編程的問題

這是一個指針函數的運用。
typedef void (*TPtr)(void* arg); 這一句是表示聲明一個返回值為void、函數指針變數名為TPtr、參數表為void型的指針arg。在typedef以下說明可以用TPtr來定義這樣一種指針函數。

TPtr SelectedItem;這一句是表示聲明一個void (*TPtr)(void* arg);類型的指針函數,該函數的指針變數名為SelectedItem。(該語句放在外面的作用是聲明)

typedef struct _TPage
{
……
TPtr SelectedItem;
……
} TPage;
表示在結構體裡面聲明一個指針變數函數。(我看他這樣麻煩,如果不是編寫內核程序,那麼他用的編譯器應該是比較原始的,因為VC6.0可以直接在結構體中定義函數,細節部分都可以交由編譯器)

TPage gActivePage;表示定義一個struct _TPage類型的結構體,結構體名稱為gActivePage。

gActivePage.SelectedItem(&gActivePage);表示調用該結構體的指針函數SelectedItem,傳入參數gActivePage。
(在這里我要說一句,你定義一個結構體的話,你必須對他進行初始化~下面是我覺得比較方便的初始化方法:memset(&gActivePage,0,sizeof(TPage));)

那麼最後我必須在告訴樓主一件事,定義的指針函數,必須對他賦值gActivePage.SelectedItem=/*某個函數名稱*/。
如果你的這段程序裡面沒有賦值部分,~恩,我只能說他寫錯了,並且無法編譯過去(要不就是你沒有貼出來~)

Ⅶ C語言編程做一個簡單的菜單

#include<stdio.h>
#include<stdlib.h>
voidmenu()//菜單繪制
{
printf("--------------------------------------- ");
printf(" 0.退出 ");
printf(" 1.錄入信息 ");
printf(" 2.查找信息 ");
printf(" 3.刪除信息 ");
printf(" 4.瀏覽信息 ");
printf(" 5.有其他疑問找群主")
printf(" 6.C++8群:491994603")
printf("--------------------------------------- ");
}

voidkeyDown()//按鍵處理
{
intchoice;
scanf("%d",&choice);
switch(choice)
{
case0:
printf("退出程序 ");
Sleep(2000);
return0;
case1:
//調用菜單1實現函數
break;
case2:
//調用菜單2實現函數
break;
case3:
//調用菜單3實現函數
break;
case4:
//調用菜單4實現函數
break;
default:
printf("輸入錯誤 ");
}
system("pause");
return0;
}
intmain()
{
while(1)
{
menu();
keyDown();
system("cls");
}
return0;
}

Ⅷ 【Help!Help!】VB 菜單編程,我是小菜鳥。

AAA,BBB,.....假設名稱為bb,在索引那裡分別寫入0,1,2.。。
Private Sub bb_Click(Index As Integer)
Text1 = ""
For i = 1 To 3
Text1 = Text1 & Asc(bb(Index).Caption) - 64
Next
End Sub

熱點內容
db2新建資料庫 發布:2024-09-08 08:10:19 瀏覽:170
頻率計源碼 發布:2024-09-08 07:40:26 瀏覽:778
奧迪a6哪個配置帶後排加熱 發布:2024-09-08 07:06:32 瀏覽:100
linux修改apache埠 發布:2024-09-08 07:05:49 瀏覽:208
有多少個不同的密碼子 發布:2024-09-08 07:00:46 瀏覽:566
linux搭建mysql伺服器配置 發布:2024-09-08 06:50:02 瀏覽:995
加上www不能訪問 發布:2024-09-08 06:39:52 瀏覽:811
銀行支付密碼器怎麼用 發布:2024-09-08 06:39:52 瀏覽:513
蘋果手機清理瀏覽器緩存怎麼清理緩存 發布:2024-09-08 06:31:32 瀏覽:554
雲伺服器的優點與缺點 發布:2024-09-08 06:30:34 瀏覽:734