Tuesday, July 14, 2009

Learning c++, more?

I've learned:


if statements


loops


switch case


arrays


strings


file i/o


functions





And well... that's it.





Where do you suggest I go to learn more?


for example, I'm a member of the website


http://hackthissite.org/


and I want to be able to do permanent programming mission 1.





To do this, you need to write a program that will check 10


randomly generated, scrambled words, against a wordlist that


you download, and then just submit the un-scrambled words


to the site.





it's not like I need GUI, i can just write the un-scrambled words


to a file, then open it and submit it.. I have 30 seconds it total.





Where do you think I should go to learn how to do this?





This is just an example of something I need to learn to do,


but if you could supply me with a site that will teach me..


basically everything, it would be greatly appreciated.


Thanks

Learning c++, more?
This is an interesting problem. So you have 30 seconds to check all the different combinations of 10 words of some undisclosed length. Since it's an undisclosed length, they could supply an extremely long word which will lag your algorithm down. Normally to find all the possible combinations of a word, you would use recursion, but this is very costly in this case. You can probably use a trie to speed the algorithm up if need be.





However, I would suggest you look into a specific data structure which best suits to solve this problem. (A nice data structures book: http://cpp.datastructures.net/chapters/i... ).





Hope this helps.
Reply:You may also talk to C++ expert live at website like http://askexpert.info/ .


C# solutions?

Suppose you have two different credit cards. A Shell master card and a Chase master card. The Shell card used at a shell gas station or minimart has a different rate rebate. The Shell Card gives a 5% rebate at the shell gas station and 0% rebate at the minimart. The Chase credit gives 3% rebate at any gas station. While driving you see both a Shell gas station and a Minimart gas station to purchase 10 gallons of gas.





Write a program that while driving you can give the voice input of the price per gallon at the Shell and Minimart gas stations and the program tells you which station to use in order to save more.











Note: This program can be extended to voice input/out interface. Currently if you just





use console or GUI interface will be fine.

C# solutions?
do your own homework you slacker


C# visual studio help please?

I a creating a drag and drop GUI and seem to have grouped 3 controls but I can't remember how to undo it, can any one please help?

C# visual studio help please?
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/...





I have always used a group box that acts as a container of controls.


C++ for beginners?

GUI vs CLI %26lt;-- what are both of them and what are the disadvantage and advantages of both of them.

C++ for beginners?
GUI is Graphical User Interface and is a point and click environment (usually) that allows you to rapidly build programs.





CLI is Command Line Interface and is used by hard core programmers to work directly with the compiler.





A compiler (if you don't know yet) is the program that takes the code you have written and converts it to the real coed that the computer uses when the program runs. The language you choose to code in is for our understanding.

surveys

I need help with this c++ code, when you find the treasure, it is suppose to turn red but it doesn't?

/* Treasure Hunt program */





#include %26lt;lvp\gui_top.h%26gt;


#include %26lt;lvp\matrix.h%26gt;


#include %26lt;lvp\string.h%26gt;


#include %26lt;lvp\bool.h%26gt;


#include %26lt;lvp\random.h%26gt;





//------------------------------------...


class ButtonClass{


public:


ButtonClass(String Text, int X1, int Y1, int X2, int Y2);


/*Post: A button created with upper-left corner at X1,Y1 and


lower-right corner at X2,Y2 with Text centeredin box */


void Paint();


bool IsHit(int x, int y);


/*Post: true returned if and only if (x,y) is on the button*/


private:


int MyX1,MyY1,MyX2,MyY2;


String MyText;


};


//------------------------------------...


ButtonClass::ButtonClass(String Text, int X1, int Y1, int X2, int Y2)


:MyText(Text),MyX1(X1),MyY1(Y1),MyX2(...


/*Post: Button created with upper-left corner at X1, Y1 and


lower right corner at X2,Y2 with Text centered in box */


{


}


//------------------------------------...


void ButtonClass::Paint()


{


SetColor(BLACK);


Rectangle(MyX1,MyY1,MyX2,MyY2);


gotoxy((MyX1+MyX2)/2, 5+(MyY1+MyY2)/2);


DrawCenteredText(MyText);


}


//------------------------------------...


bool ButtonClass::IsHit(int x, int y)


/*Post: true returned if and only if point (x,y) is on the button */


{


return (x%26gt;=MyX1 %26amp;%26amp; x%26lt;=MyX2 %26amp;%26amp; y%26gt;=MyY1 %26amp;%26amp; y%26lt;=MyY2);


}


//------------------------------------...


//------------------------------------...





class GridClass {


public:


GridClass();


void Paint();


void MouseClick(int x, int y);


void InitGrid();


private:


const int GridDimension; // # of rows and columns in grid


// Constants for board; must all differ


const int Empty, EmptyPicked, Treasure, TreasurePicked;


matrix%26lt;int%26gt; Board; // Uses above constants


int TreasureRow, TreasureCol;


bool GameOver;


int NumClicks;


int BoxSize; // Pixels per box


int LeftMargin; // Pixels from left


int TopMargin; // Pixels from top


void XYToRowCol(int x, int y, int %26amp;Row, int %26amp;Col);


void MarkBox(int Row, int Col, int BoxContents);


ButtonClass QuitButton;


};


//------------------------------------...


GridClass::GridClass()


: GridDimension(5),


Empty(0), EmptyPicked(-1), Treasure(1), TreasurePicked(2),


Board(GridDimension, GridDimension,0),


NumClicks(0), GameOver(false),


BoxSize(GetMaxY()/2/GridDimension), // Fill half of y


LeftMargin((GetMaxX()-BoxSize*GridDim...


TopMargin(GetMaxY()/4),


QuitButton("I give up!",10,10,100,40)


{


randomize();


TreasureRow = random(GridDimension);


TreasureCol= random(GridDimension);


Board[TreasureRow][TreasureCol] = Treasure;


}


//------------------------------------...


void GridClass::InitGrid()


/*Post: Grid initialized for a new game */


{


NumClicks = 0;


GameOver = false;


for (int Row=0; Row %26lt; GridDimension; Row++)


for (int Col=0; Col %26lt; GridDimension; Col++)


Board[Row][Col] = Empty;


TreasureRow = random(GridDimension);


TreasureCol = random(GridDimension);


Board[TreasureRow][TreasureCol] = Treasure;


}


//------------------------------------...


void GridClass::XYToRowCol(int x, int y, int %26amp;Row, int %26amp;Col)


/* Post: Row and Column corresponding to x, y returned,


or -1 returned if x, y is not on the board */


{


int DistFromLeft = x - LeftMargin;


Col = (DistFromLeft+BoxSize)/BoxSize-1;


int DistFromTop = y - TopMargin;


Row = (DistFromTop+BoxSize)/BoxSize-1;


if (Col %26lt; 0 || Col %26gt;= GridDimension ||


Row %26lt; 0 || Row %26gt;= GridDimension) {


Row = -1;


Col = -1;


}


}


//------------------------------------...


void GridClass::MarkBox(int Row, int Col, int BoxContents)


/* Post: Row, Col box in appropriate color */


{


SetColor(BLACK); // For outline


SetFillColor(WHITE);


if (BoxContents==EmptyPicked)


SetFillColor(GRAY);


else if (BoxContents==TreasurePicked)


SetFillColor(RED);


FilledRectangle(Col*BoxSize+LeftMargi... Row*BoxSize+TopMargin,


(Col+1)*BoxSize+LeftMargin,


(Row+1)*BoxSize+TopMargin);


}


//------------------------------------...


void GridClass::MouseClick(int x, int y)


{


int Row, Col;


if (QuitButton.IsHit(x,y)){


GameOver = true;


Board[TreasureRow][TreasureCol] = TreasurePicked;


Paint(); //To show the treasure square


MessageBox("Come back again!","Quit button clicked");


PostQuitMessage(0);


}


else{


XYToRowCol(x, y, Row, Col);


if (Row != -1 %26amp;%26amp; Col!= -1 %26amp;%26amp; Board[Row][Col] != EmptyPicked) {


if (Board[Row][Col] == Empty)


Board[Row][Col] = EmptyPicked;


else if (Board[Row][Col] == Treasure) {


Board[Row][Col] = TreasurePicked;


GameOver = true;


Paint(); //To show treasure square


if (MessageBoxYN("Play again?","Game over")==1)


InitGrid();


else


PostQuitMessage(0);


}


NumClicks++;


}


else


MessageBeep(-1);


}


}


//------------------------------------...


void GridClass::Paint()


{


QuitButton.Paint();


SetColor(BLACK);





int Row,Col;


// Draw lines


for (Col = 0; Col %26lt;= GridDimension; Col++)


Line(LeftMargin+Col*BoxSize, TopMargin,


LeftMargin+Col*BoxSize,


TopMargin+GridDimension*BoxSize);


for (Row = 0; Row %26lt;= GridDimension; Row++)


Line(LeftMargin, TopMargin+Row*BoxSize,


LeftMargin+GridDimension*BoxSize,


TopMargin+Row*BoxSize);


// Color in boxes


for (Row=0; Row %26lt; GridDimension; Row++)


for (Col=0; Col %26lt; GridDimension; Col++)


MarkBox(Row, Col, Board[Row][Col]);


// Display results


if (GameOver==true) {


gotoxy(20, GetMaxY()-60);


DrawText("Game over! Score = ");


DrawText(NumClicks);


}


}


//------------------------------------...


//------------------------------------...


class GuiClass {


public:


GuiClass();


void GuiMouseClick(int x, int y); // Action if mouse click


void GuiPaint(); // Repaint the entire window


String Title(); // Title to display


private:


GridClass Game;


};


//------------------------------------...


GuiClass::GuiClass()


{


}


//------------------------------------...


String GuiClass::Title()


{


return ("Treasure hunt!");


}


//------------------------------------...


void GuiClass::GuiMouseClick(int x, int y)


{


Game.MouseClick(x, y);


}


//------------------------------------...


void GuiClass::GuiPaint()


{


Game.Paint();


}


//------------------------------------...


#include %26lt;lvp\gui_bot.h%26gt;

I need help with this c++ code, when you find the treasure, it is suppose to turn red but it doesn't?
http://www.devarticles.com/c/b/Cplusplus...





http://www.codeproject.com/





http://www.cprogramming.com/


Java codes: How to write a java application (using GUI) to implement a simple Calculator???

The calculator should perform 4 operations (addition, subtraction, multiplication and division). The calculator should contain a button called clear that will clear the last input of the formula (forexample, 3+4 then "button clear" deletes 4 only) and also the calculator should contain another button called C/A that will clear all the input. And also the calculator should contain a button called Off to exit.

Java codes: How to write a java application (using GUI) to implement a simple Calculator???
Hmm, sounds like a homework assignment...





The GUI is really straightforward. Use two JPanels, one to hold the buttons and one to contain the entire calculator. Use a GridLayout on the one with the buttons and a BorderLayout on the overall panel (so you can get the text box across the top.) If you really wanted to I guess you could do a GridBagLayout, but it's easier to combine the simpler ones. For the calculations, use two Stacks, one that holds doubles or floats to hold your numbers, and one that holds ints representing your operations. Define constants such as Calculator.ADD and Calculator.DIVIDE to store in the operator stack. When the user clicks a number button it will append that number to the number in the text field. When an operation button is clicked, add the number in the text field to the numerical stack. When equals is clicked, iterate through both stacks until you have a result. A better method would be to show the entire equation in the text window and wait until equals is pressed to evaluate to allow for complex equations. This would require you to code a standard-to-postscript evaluator, which is a bit above what you need to complete this project.
Reply:Get Eclipse and use Java swing. Jbuttons, Jframes, Jtextfields etc. It is too much to put in an answer.
Reply:If you want me to write this program for you then tough. I don't have a GUI editor.





The best thing for you to do is to picture on paper or in your mind the actions that are required.





First you will need to type in a number. The number will be typed in one digit at a time and appear on the "display". You will be using the calculator keypad for this so each number will have to update the "display".


You will now press an operation key, but no operation will be performed at this stage in this example. (The final program may be different to this) but you will need to store the operation.


Now you enter another number. This second number will refresh the "display" but you will need to store the previous number because you have an operation to process.


Now you press any operation key or an equals operation and the previous operation will be performed. The result will be shown on the "display".





I think you will find that this is called a use case. A very important tool in the development of OO programs.


Or of course you could always just cobble something together and hope that it works.


How to open windows gui from the dos prompt?

When I tried to install an XP cd, I get a DOS c: prompt. What do I do?

How to open windows gui from the dos prompt?
If you are installing WinXP:


1- Go to your CD (like E:) by typing E: then enter


2- type cd i386 then enter


3- type winnt


4- it will ask you (May be) for the cd rom drive letter.
Reply:Type exit


Then press the Enter key