注册 登录
编程论坛 版务及公告

入境随俗:《编程论坛生存手册》

静夜思 发布于 2007-07-05 19:12, 374758 次点击
[bo]如果想在论坛玩的更开心一些,有更多的收获,更受人欢迎,建议多了解了解下面的规则:[/bo]

[bo]1、在自己得到了别人的帮助以后,一定在最后总结一下,请不要一声不吭的走人。[/bo]
总结的内容包括:1、问题到底出在哪里。2、通过第几楼的方法解决的。
这种总结,其他人很有用,通过看总结他们可以知道第几楼的方法是对的。
在自己的求助帖最后做总结是对其他人的奉献,是对高手最好的回报。
如果嫌总结浪费自己的时间,麻烦您最后简短的说声“谢谢”吧。
[bo]2、请把帖子的主要内容在标题中表述出来(直接关系到别人对帖子的兴趣)[/bo]
“求助”“急”“请教高手”、“大侠救命”这些都是废话,到底要请教什么问题,哪个地
方不懂都在标题中写出来,让别人一看就知道你的问题出在什么地方,这样才不至于没人回。
具体见:提问的智慧(强烈推荐阅读)
[bo]3、严禁对他人进行辱骂等人身攻击。[/bo]
不论事发的原因,不论多高的等级,不论多高的威望,不论在论坛中有多高的威信,只要出口骂人,
在对方提出投诉以后马上封ID。
2868 回复
#1852
luipong5202008-07-03 10:09
嗯 说的有道理。
#1853
zhizhai2008-07-03 10:27
好,就要这样,大家都要有感恩的心.感谢大家!有感才有应啊!
#1854
wangqiulei2008-07-03 10:52
入门
谢谢指导。
#1855
苦乐年华2008-07-03 11:58
hao
#1856
hongwuhan2008-07-04 01:13
支持
#1857
jmjljl2008-07-04 10:03
drtgdf
fgvdfgdf
#1858
nisilma2008-07-04 12:07
请问一下VB编程有什么实际用处
我是新手 想知道以下
#1859
天空飘云2008-07-05 09:54
我是新手 以后请各位多多指点
#1860
高世锋2008-07-05 11:46
#1861
kingoftheworld2008-07-05 15:31
简单
没用main函数
#1862
aliciersky2008-07-05 20:07
支持了
  我对这些都不怎么熟悉 主要是来学习的
#1863
sxby_012008-07-06 00:07
回复 1# 静夜思 的帖子
谢谢
#1864
飞猪设计2008-07-06 03:41
顶   .......
#1865
yang53127752008-07-06 15:28
将支持进行到底
新手初来咋到,请大家支持支持
#1866
龙龙爱着徐琼2008-07-06 20:00
错哪了?
#include <stdio.h>
#include <conio.h>
#include <bios.h>

#define NULL 0
typedef struct menu
{
    int ID;
    int x;
    int y;
    int active;
    char content[20];
    struct menu *pSubMenu;
    int n_SubMenu;
}MENU;
#define FILE 1
#define EDIT 2
#define SORT 3
#define FILTER 4
#define HELP 5
#define FILE_NEW 11
#define FILE_OPEN 12
#define FILE_SAVE 13
#define FILE_SAVEAS 14
#define FILE_CLOSE 15
#define FILE_EXIT 16
#define EDIT_ADD 21
#define EDIT_DEL 22
#define EDIT_MOD 23
#define SORT_NUM 31
#define SORT_NAME 32
#define FILTER_NUM 41
#define FILTER_NAME 42
#define FILTER_NEW 43
#define HELP_HELP 51
#define HELP_ABOUT 52
MENU FileSub[6]={
        {FILE_NEW,1,2,1,"New",NULL,0},
        {FILE_OPEN,1,3,0,"Open",NULL,0},
        {FILE_SAVE,1,4,0,"Save",NULL,0},
        {FILE_SAVEAS,1,5,0,"Save As",NULL,0},
        {FILE_CLOSE,1,6,0,"Close",NULL,0},
        {FILE_EXIT,1,7,0,"Exit",NULL,0}
        };
MENU EditSub[3]={
        {EDIT_ADD,15,2,1,"Add",NULL,0},
        {EDIT_DEL,15,3,0,"Delete",NULL,0},
        {EDIT_MOD,15,4,0,"Modify",NULL,0}
        };
MENU SortSub[2]={
        {SORT_NUM,30,2,1,"Number",NULL,0},
        {SORT_NAME,30,3,0,"Name",NULL,0}
        };
MENU FilterSub[3]={
        {FILTER_NUM,45,2,1,"Number",NULL,0},
        {FILTER_NAME,45,3,0,"Name",NULL,0},
        {FILTER_NEW,45,4,0,"New",NULL,0}
        };
MENU HelpSub[2]={
        {HELP_HELP,60,2,1,"Help",NULL,0},
        {HELP_ABOUT,60,3,0,"About",NULL,0}
        };
MENU MainMenu[5]={
        {FILE,1,1,0,"File",FileSub,6},
        {EDIT,15,1,0,"Edit",EditSub,3},
        {SORT,30,1,0,"Sort",SortSub,2},
        {FILTER,45,1,0,"Fileter",FilterSub,3},
        {HELP,60,1,0,"Help",HelpSub,2}
        };
void MenuDraw(MENU *pMenu,int n)
{
    window(1,1,80,25);
    for(;n>0;n--)
    {
        textbackground(pMenu->active?BLUE:WHITE);
        textcolor(RED);
        gotoxy(pMenu->x,pMenu->y);
        cprintf("%s",pMenu->content);
        pMenu++;
    }
}
void FrameDraw()
{
    int i,j;
    textbackground(BLACK);
    clrscr();
    window(1,1,80,25);
    textbackground(WHITE);
    clrscr();
    window(1,25,80,25);
    clrscr();
    textbackground(CYAN);
    textcolor(BLACK);
    window(1,2,80,2);
    clrscr();
    window(1,24,80,24);
    clrscr();
    window(1,2,1,24);
    clrscr();
    window(80,2,80,24);
    clrscr();

    window(1,1,80,25);
    for(i=2;i<80;i++)
    {
        gotoxy(i,2);
        cprintf("%c",205);
        gotoxy(i,24);
        cprintf("%c",205);
    }
    for(j=3;j<24;j++)
    {
        gotoxy(1,j);
        cprintf("%c",186);
        gotoxy(80,j);
        cprintf("%c",186);
    }
    gotoxy(1,2);cprintf("%c",201);
    gotoxy(80,2);cprintf("%c",187);
    gotoxy(1,24);cprintf("%c",200);
    gotoxy(80,24);cprintf("%c",188);
    textbackground(WHITE);
    window(2,3,4,23);
    clrscr();
    textbackground(BLACK);
    window(5,3,54,23);
    clrscr();
    textbackground(YELLOW);
    window(56,3,79,12);
    clrscr();
    textbackground(BLUE);
    window(56,14,79,23);
    clrscr();
    window(1,1,80,25);
    textcolor(BLACK);
    textbackground(CYAN);
    for(j=3;j<24;j++)
    {
        gotoxy(55,j);
        cprintf("%c",186);
    }
    for(i=56;i<80;i++)
    {
        gotoxy(i,13);
        cprintf("%c",205);
    }
    gotoxy(55,2);cprintf("%c",203);
    gotoxy(55,24);cprintf("%c",202);
    gotoxy(55,13);cprintf("%c",204);
    gotoxy(80,13);cprintf("%c",185);
    
    gotoxy(21,2);cprintf("Student List");
    gotoxy(60,2);cprintf("Filter Information");
    gotoxy(60,13);cprintf("Input Information");

    gotoxy(4,3);cprintf("No.");
    gotoxy(14,3);cprintf("Name");
    gotoxy(30,3);cprintf("Age");
    gotoxy(35,3);cprintf("Address");

    MenuDraw(MainMenu,5);
}

#define UP_KEY 0x4800
#define DOWN_KEY 0x5000
#define LEFT_KEY 0x4b00
#define RIGHT_KEY 0x4d00
#define F10_KEY 0x4400
#define RETURN_KEY 0x1c0d
#define BS_KEY 0x0e08
#define ESC_KEY 0x011b
int MenuSelect()
{
    int b_Exit=0;
    int result=0;
    int b_SubMenu=0;
    int left=1,top=1,right=1,bottom=1,n;
    char buffer[500];
    MainMenu[0].active=1;
    MenuDraw(MainMenu,5);
    while(!b_Exit)
    {
        switch(bioskey(0))
        {
            case F10_KEY:
            if(b_SubMenu)
            {
                b_SubMenu=0;
                puttext(left,top,right,bottom,buffer);
            }break;
            case ESC_KEY:
            n=SearchActiveMenu(MainMenu,5);
            MainMenu[n].active=0;
            if(b_SubMenu)
            {
                puttext(left,top,right,bottom,buffer);
            }
            MenuDraw(MainMenu,5);result=0;b_Exit=1;break;
            case UP_KEY:
            if(b_SubMenu)
            {
                int m;
                n=SearchActiveMenu(MainMenu,5);
                m=SearchActiveMenu(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
                (MainMenu[n].pSubMenu+m)->active=0;
                if(m==0)
                {
                    (MainMenu[n].pSubMenu+MainMenu[n].n_SubMenu-1)->active=1;
                }
                else
                {
                    (MainMenu[n].pSubMenu+m-1)->active=1;
                }
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;
            case DOWN_KEY:
            if(b_SubMenu)
            {
                int m;n=SearchActiveMenu(MainMenu,5);
                m=SearchActiveMenu(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
                (MainMenu[n].pSubMenu+m)->active=0;
                if(m==(MainMenu[n].n_SubMenu-1))
                {
                    MainMenu[n].pSubMenu->active=1;
                }
                else
                {
                    (MainMenu[n].pSubMenu+m+1)->active=1;
                }
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;    
            case LEFT_KEY:
            n=SearchActiveMenu(MainMenu,5);
            MainMenu[n].active=0;
            n=(n==0)?4:(n-1);
            MainMenu[n].active=1;
            MenuDraw(MainMenu,5);
            if(b_SubMenu)
            {
                puttext(left,top,right,bottom,buffer);
                left=MainMenu[n].pSubMenu->x;
                top=2;
                right=left+20;
                bottom=top+MainMenu[n].n_SubMenu-1;
                gettext(left,top,right,bottom,buffer);
                window(left,top,right,bottom);
                textbackground(WHITE);
                clrscr();
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;
            case RIGHT_KEY:
            n=SearchActiveMenu(MainMenu,5);
            MainMenu[n].active=0;
            n=(n+1)%5;
            MainMenu[n].active=1;
            MenuDraw(MainMenu,5);
            if(b_SubMenu)
            {
                puttext(left,top,right,bottom,buffer);
                left=MainMenu[n].pSubMenu->x;
                top=2;right=left+20;
                bottom=top+MainMenu[n].n_SubMenu-1;
                gettext(left,top,right,bottom,buffer);
                window(left,top,right,bottom);
                textbackground(WHITE);
                clrscr();
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }break;
            case RETURN_KEY:
            n=SearchActiveMenu(MainMenu,5);
            if(!b_SubMenu)
            {
                b_SubMenu=1;
                left=MainMenu[n].pSubMenu->x;
                top=2;right=left+20;
                bottom=top+MainMenu[n].n_SubMenu-1;
                gettext(left,top,right,bottom,buffer);
                window(left,top,right,bottom);
                textbackground(WHITE);
                clrscr();
                MenuDraw(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
            }
            else
            {
                int m;
                m=SearchActiveMenu(MainMenu[n].pSubMenu,MainMenu[n].n_SubMenu);
                result=(MainMenu[n].pSubMenu+m)->ID;
                MainMenu[n].active=0;
                puttext(left,top,right,bottom,buffer);
                MenuDraw(MainMenu,5);
                b_Exit=1;
            }
        }break;
    }return(result);

}
int SearchActiveMenu(MENU *pMenu,int n)
{
    for(n--;n>=0;n--)
    {
        if(pMenu[n].active) break;
    }return(n);
}




main()
{    
    int b_Exit=0;
    /*textmod(C80);*/
    textbackground(BLACK);
    textcolor(WHITE);
    clrscr();
    FrameDraw();

    while(!b_Exit)
    {
        switch(bioskey(0))
        {
            case F10_KEY:
            if(MenuSelect()==FILE_EXIT)
            b_Exit=1;
            case UP_KEY:
            case DOWN_KEY:break;
        }
    }
}
多多指教
#1867
VFive2008-07-07 02:46
菜鸟收到,希望各位大牛多多关照
#1868
fyjzmx20002008-07-07 09:43
来学习一下
#1869
totti1332008-07-07 10:16
555555555555555
#include <iostream>
#include <algorithm>
#include <iterator>
#include <ctime>
using namespace std;
/** arrange the two colors so that color a sits on the left,
color c sits on the right.
Time complexity is O(n), space complexity is O(1). Thus it is
the best algorithm one could have.
*/
void arrangeAC(char*a, int n);
void swap(char& i, char& j);
// randome generator for an array consisting of colors a and c.
void randomGenerator(char* arr, int size);

int main(int argc, char** argv)
{
// prepare the array
int kSize;
cout<<"Please input a number n (n>0): ";
cin>>kSize;
char *a = new char[kSize];
randomGenerator (a, kSize);
cout<<"The oringinal matrix is:\n";
copy(a, a+kSize, std::ostream_iterator<char>(cout, " "));
cout<<endl;
cout<<"----------------------------------------------------------------------\n";
arrangeAC(a, kSize);
cout<<"The arranged matrix is:\n";
copy(a, a+kSize, std::ostream_iterator<char>(cout, " "));
cout<<endl;
delete [] a;
return 0;
}
void arrangeAC(char *a, int n)
{
/**
These 3 variables are the 3 pointers of your case.
*/
int aMarker = 0;
int cMarker = n-1;
int i = 1;
// on the left of a marker, all colors are a
while ( a[aMarker] == 'a' )
{
++aMarker;
}
// on the right of c marker, all colors are c
while ( a[cMarker] == 'c')
{
--cMarker;
}
i = aMarker+1;
while (i <= cMarker)
{
if(a[i] == 'a')
{
if( i > aMarker )
{
swap(a[i], a[aMarker]);
++aMarker;
}
else
++i;
}
else
{
swap(a[i], a[cMarker]);
--cMarker;
}
}
}
void swap(char& i, char& j)
{
char temp = i;
i = j;
j = temp;
}
void randomGenerator(char* arr, int size)
{
srand(time(NULL));
for(int i=0; i<size; ++i)
{
arr[i] = ( (rand() | (rand()<<16) ) % 2 == 0 ? 'a' : 'c');
}
}
谁跟我解释下意思啊
#1870
蓝色的雪2008-07-07 14:38
谢谢前辈的指点,小弟知道了!出来乍到,受益颇多,请各位多多指教!
#1871
小周19892008-07-07 15:41
顶起
#1872
牧人羊2008-07-07 16:42
新来的,顶!
#1873
sanjinufo2008-07-07 16:58
恩 大家要做文明人 支持
#1874
ls31362008-07-08 10:34
新手上路,初学C#,还请多多指教!
#1875
无雪的冬天2008-07-08 13:55
看到,顶一下!
#1876
sysdown2008-07-08 14:27
新手上路

支持!
#1877
wodedaxuehust2008-07-08 20:58
我是新手支持楼主
我是新手一定支持版主,希望和大家一起交流
#1878
abab5522008-07-08 22:19
kxcdk
#1879
maoguo0042008-07-09 08:14
在找找
#1880
IceWee2008-07-09 08:37
对第一点非常的支持与赞同!顶
#1881
天使之春2008-07-09 09:01
顶!!!支持!!!
#1882
xjhtgxd20062008-07-09 10:06
支持!
#1883
X新手Y2008-07-09 19:27
支持!
#1884
ni88hao2008-07-09 20:13
那就谢谢了,o(∩_∩)o...
#1885
clblj2008-07-09 20:38
支持
#1886
yshen2008-07-09 22:11


强烈支持!
#1887
liaomingfu5202008-07-09 22:28
我也鼎鼎
#1888
chenjianqpb2008-07-10 16:58
新手学习,,,,报到,
#1889
kcat2008-07-11 00:00
很好`
#1890
aiyang3292008-07-11 09:55
做人要有始有终,支持楼主
#1891
kevin07272008-07-11 11:53
支持。
#1892
hurtsky2008-07-11 21:31
找热爱编程的朋友!
一起学习,一起探讨。
#1893
zzmwmh2008-07-12 14:18
新手,下不了东西。。。。
#1894
hugh20062008-07-12 14:34
我会尽量作的
我会尽量作的,谢谢提醒
#1895
kfy06272008-07-12 18:39
学习了。一定好好在这里生存。
#1896
sdmfl2008-07-12 20:34
支持!
#1897
leo80002008-07-12 20:40
支持!!!!!!!!!!!!!!!!
#1898
wanwentao2008-07-12 20:54
强烈支持。
#1899
YCVSCY2008-07-12 21:45
是的!
#1900
梦境2008-07-12 23:14
支持
#1901
入学式2008-07-13 11:37
永远支持
12.....343536373839404142.....5758