int WindowLister( int x, int y, int xx, int yy, int CharToExitOn, int *NumItems, int NumToStartWith, int (*CharHandler)(int ch, int Index), void (*ScreenClearer)( void ), void (*DisplayLineFunction)(int Index) ) { register int i; register int CurrLine = 0; int PrevLine; int NumLines = yy - y; int Top = NumToStartWith; int OldTop; int RefreshScreen = 1; int ch; union REGS regs, regs2; int Index; regs.x.cx = ( (y-1) << 8 ) + x-1; regs.x.dx = ( (yy-1) << 8 ) + xx-1; regs.x.ax = 0; regs.h.bh = A_NORMAL; regs.h.ah = 0x06; regs.x.ax = 1; for (;;) { if ( RefreshScreen ) { ScreenClearer(); ChangeBlock( x, y, xx, yy, A_NORMAL ); RefreshScreen = 0; PrevLine = 500; OldTop = -500; for (i=0; i<=NumLines; ++i) { gotoxy( x, i+y ); if ( i+Top <= *NumItems ) DisplayLineFunction( i+Top ); } } Index = CurrLine + Top; if ( PrevLine != CurrLine || OldTop != Top ) { SetAttrib( A_REVERSE ); gotoxy( x, y + CurrLine ); DisplayLineFunction( Index ); SetAttrib( A_NORMAL ); } HideCursor(); PrevLine = CurrLine; OldTop = Top; ch = GComm(); if ( ch == CharToExitOn ) return( Index ); switch( ch ) { case ESC: return( -1 ); case DOWN: CurrLine++; if (CurrLine > NumLines) { CurrLine = NumLines; if ( Top < *NumItems - NumLines ) { Top++; ChangeBlock( x, y, xx, yy, A_NORMAL ); regs.h.ah = 0x06; int86( 0x10, ®s, ®s2 ); gotoxy( x, yy ); } } break; case UP: CurrLine--; if (CurrLine < 0) { CurrLine=0; if ( Top > 0 ) { Top--; ChangeBlock( x, yy, xx, yy, A_NORMAL ); regs.h.ah = 7; int86( 0x10, ®s, ®s2 ); gotoxy( x, y ); } } break; case END: Top = *NumItems - NumLines; if ( Top < 0 ) { Top = 0; } CurrLine = NumLines; if ( CurrLine > *NumItems ) { CurrLine = *NumItems; } RefreshScreen++; break; case PGDN: Top += NumLines; if (Top > *NumItems - NumLines) { Top = *NumItems - NumLines; if ( Top < 0 ) Top = 0; CurrLine = NumLines; if ( CurrLine > *NumItems ) { CurrLine = *NumItems; } } RefreshScreen++; break; case PGUP: Top -= NumLines; if (Top < 0) { Top = 0; CurrLine = 0; } RefreshScreen++; break; case HOME: Top = CurrLine = 0; RefreshScreen++; break; default: gotoxy( x, CurrLine + y ); ReverseText(); DisplayLineFunction( Index ); NormalText(); /*HideCursor();*/ RefreshScreen++; CurrLine = CharHandler( ch, Index ); RefreshScreen = 1; if ( CurrLine - Top <= NumLines && CurrLine - Top >= 0 ) CurrLine -= Top; else { Top = CurrLine - 1; CurrLine = 1; if ( Top < 0 ) { Top = CurrLine = 0; } } break; } if ( Top < 0 ) { Top = 0; CurrLine = 0; } if ( Top + CurrLine > *NumItems ) { CurrLine = *NumItems - Top; } if ( PrevLine != CurrLine || Top != OldTop ) { ChangeBlock( x, y, xx, yy, A_NORMAL ); } if ( RefreshScreen > 1 ) { Top = CurrLine = 0; } } }
void part_four_describe() { bool flag=true; while(flag) { cout<<"******************************************"<<endl; cout<<"* 第四章 ACM程序设计实战 *"<<endl; cout<<"******************************************"<<endl; cout<<"*(1)Quicksum *"<<endl; cout<<"*(2)IBM Minus One *"<<endl; cout<<"*(3)Binary Numbers *"<<endl; cout<<"*(4)Encoding *"<<endl; cout<<"*(5)Look and Say *"<<endl; cout<<"*(6)Abbreviation *"<<endl; cout<<"*(7)The Seven Percent Solution *"<<endl; cout<<"*(8)Digital Roots *"<<endl; cout<<"*(9)Box of Bricks *"<<endl; cout<<"*(10)Geometry Made Simple *"<<endl; cout<<"*(11)Reverse Text *"<<endl; cout<<"*(12)Word Reversal* *"<<endl; cout<<"*(13)A Simple Question of Chemistry *"<<endl; cout<<"*(14)Adding Reversed Numbers *"<<endl; cout<<"*(15)Image Transformation *"<<endl; cout<<"*(16)Beautiful Meadow *"<<endl; cout<<"*(17)DNA Sorting *"<<endl; cout<<"*(18)Daffodil Number *"<<endl; cout<<"*(19)Error Correction *"<<endl; cout<<"*(20)Martian Addition *"<<endl; cout<<"*(21)FatMouse’ Trade *"<<endl; cout<<"*(22)List the Books *"<<endl; cout<<"*(23)Head-to-Head Match *"<<endl; cout<<"*(24)Windows Message Queue *"<<endl; cout<<"*(25)Language of FatMouse *"<<endl; cout<<"*(26)Palindromes *"<<endl; cout<<"*(27)Root of the Problem *"<<endl; cout<<"*(28)Magic Square *"<<endl; cout<<"*(29)Semi-Prime *"<<endl; cout<<"*(30)Beautiful Number *"<<endl; cout<<"*(31)Phone List *"<<endl; cout<<"*(32)Calendar *"<<endl; cout<<"*(33)No Brainer *"<<endl; cout<<"*(34)Quick Change *"<<endl; cout<<"*(35)Total Amount *"<<endl; cout<<"*(36)Electrical Outlets *"<<endl; cout<<"*(37)Speed Limit *"<<endl; cout<<"*(38)Beat the Spread! *"<<endl; cout<<"*(39)Champion of the Swordsmanship *"<<endl; cout<<"*(40)Doubles *"<<endl; cout<<"*(41)File Searching *"<<endl; cout<<"*(42)Old Bill *"<<endl; cout<<"*(43)Divisor Summation *"<<endl; cout<<"*(44)Easier Done Than Said? *"<<endl; cout<<"*(45)Let the Balloon Rise *"<<endl; cout<<"*(46)The Hardest Problem Ever *"<<endl; cout<<"*(47)Fibonacci Again *"<<endl; cout<<"*(48)Excuses, Excuses! *"<<endl; cout<<"*(49)Lowest Bit *"<<endl; cout<<"*(50)Longest Ordered Subsequence *"<<endl; cout<<"******************************************"<<endl; cout<<"请输入对应的编号进入相应的题目(返回上级输入0):"<<endl; int num; cin>>num; while(num<0&&num>50){ cout<<"编号不存在"<<endl; cout<<"请输入对应的编号进入相应的题目(返回上级输入0):"<<endl; cin>>num; } switch(num){ case 0:flag=false;break; case 1:QuickSum();break; case 2:IBMMinusOne();break; case 3:BinaryNumbers();break; case 4:Encoding();break; case 5:LookAndSay();break; case 6:Abbreviation();break; case 7:TheSevenPercentSolution();break; case 8:DigitalRoots();break; case 9:BoxofBricks();break; case 10:GeometryMadeSimple();break; case 11:ReverseText();break; case 12:WordReversal();break; case 13:ASimpleQuestionofChemistry();break; case 14:AddingReversedNumbers();break; case 15:ImageTransformation();break; case 16:BeautifulMeadow();break; case 17:DNASorting();break; case 18:DaffodilNumber();break; case 19:ErrorCorrection();break; case 20:MartianAddition();break; case 21:FatMouseTrade();break; case 22:ListtheBooks();break; case 23:HeadToHeadMatch();break; case 24:WindowsMessageQueue();break; case 25:LanguageofFatMouse();break; case 26:Palindromes();break; case 27:RootoftheProblem();break; case 28:MagicSquare();break; case 29:SemiPrime();break; case 30:BeautifulNumber();break; case 31:PhoneList();break; case 32:Calendar();break; case 33:NoBrainer();break; case 34:QuickChange();break; case 35:TotalAmount();break; case 36:ElectricalOutlets();break; case 37:SpeedLimit();break; case 38:BeattheSpread();break; case 39:ChampionoftheSwordsmanship();break; case 40:Doubles();break; case 41:FileSearching();break; case 42:OldBill();break; case 43:DivisorSummation();break; case 44:EasierDoneThanSaid();break; case 45:LettheBalloonRise();break; case 46:TheHardestProblemEver();break; case 47:FibonacciAgain();break; case 48:ExcusesExcuses();break; case 49:LowestBit();break; case 50:LongestOrderedSubsequence();break; //case 3:part_three_describe();break; //case 4:part_four_describe();break; } } total_describe(); }