dev-cpp-users Mailing List for Dev-C++ (Page 683)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Luigi S. <gi...@li...> - 2001-07-22 04:08:46
|
Barbara -
Here is how to get started with console programming in Dev C++.
1) To build the program
- create the directory where you will be working (say it "c:\bar")
- open Dev C++
- choose "File - New Project"
- choose console application and C Project
- give a name to your project, say: "hw"
- select the place where you want your project to be saved (of course this
will be "c:\bar")
- you should know see: the project manager to the left and the file
"untitled" opened in the edit window.
- fill the file "untitled" with your program (say: printf("hello world!\n");)
- save the file by: "File - Save Unit", lets say that you name it "hello"
(hello.c will be created).
- To build your project use either: "Execute - Compile" or "Ctrl + F9"
(this will create the file hw.exe in c:\bar)
2) To execute the program (I assume you are using Windows)
- Open a DOS box
- move to "c:\bar"
- launch: "hw"
If you wish, you can execute the program from Dev C++ IDE (like you usually
do with Turbo C), in this case:
- add, just before the return statement, the following line : getchar();
- now compile the program again, so that the executable file is updated (in
other words: press Ctrl + F9)
- Execute by "Execute - Run" or by pressing F9.
- Your program should now pause and let you read the screen.
- press any key (for example q) and then press return to end the execution
Have fun ...
P.S. If you want me to answer in your language then let me know.
At 17.36 21/07/01 +0200, you wrote:
>I've downloaded DEV C++.
>I've started to programme and I'm quite helpless.
>I can't see the window I generally have in Turbo-C when I do ALT F5 or
>Window/userscreen.
>You know I'm quite helpless and I have just few notions of programming.
>Besides I'm not english mother-tongue (I'm italian).
>Please, if someone may.... explain me in a really simple way step by step.
>
>Thanks.
>
>Barbara.
>
>
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
--
gisan
gi...@li...
|
|
From: Adam J. <sou...@ho...> - 2001-07-22 04:02:08
|
<html><div style='background-color:'><DIV> <P><BR><BR>REMOVE ME FROM THIS GODDAMNED LIST, ITS FLOODING MY INBOX WITHTWENTY FRIGGIN EMAILS A DAY!</P></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html> |
|
From: Mark B. <al...@bi...> - 2001-07-22 01:35:05
|
Jarred,
cout requires the << before every argument as below.
#include <iostream.h>
#include <stdlib.h>
int main()
{
int x = 5;
int y = 7;
cout << "\n";
cout << x + y << " " << x*y;
cout << "\n";
system("PAUSE");
return 0;
}
Regards,
Mark Ballard
ma...@du...
|
|
From: Ioannis V. <no...@ya...> - 2001-07-21 23:36:13
|
Basically class Rings is a whole mistake. You define const built in
arrays in the constructor, and you probably want to define them as
members of the class. You initialize them before their definition in the
constructor (as you should if they were defined as members of the
class), and you initialize in the wrong way. The initialization goes
=3D"string"; or=3D{values} and not ("string"). Perhaps it is better to
define the arrays as char const *const pointers pointing to "string"
where you could use the () notation.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Julio Lajara
> Sent: Sunday, July 22, 2001 12:42 AM
> To: dev...@li...
> Subject: [Dev-C++] I dont see the error in my code, I need=20
> help with this.......
>=20
>=20
> This program has no other problems(ignoring the fact
> that I am assigning rings to the dimensions of the
> board) excpet that when I try to compile it, it says
> parse error at end of input, and I dont see it.
>=20
> #include <iostream.h>
> #include <stdlib.h>
> #include "Tower Ring Class.hpp"
>=20
> //function prototypes
>=20
> void gameBoard(char square[10][3]);
> void playGame(char square[10][3]);
>=20
> //This class creates te rings that will be placed on
> the gameBoard
>=20
> class Rings
> {
> Rings():
> rings1[4]("777"),=20
> rings2[6]("77777"),
> rings3[8]("7777777"),
> rings4[10]("777777777"),
> rings5[12]("77777777777"),
> rings6[14]("7777777777777"),
> rings7[16]("777777777777777"),
> rings8[18]("77777777777777777"),
> rings9[20]("7777777777777777777"),
> rings10[22]("777777777777777777777"),
> rings11[4](" "),
> rings12[6](" "),
> rings13[8](" "),
> rings14[10](" "),
> rings15[12](" "),
> rings16[14]{" "),
> rings17[16](" "),
> rings18[18](" "),
> rings19[20](" "),
> rings20[22](" ")
> {
> const char rings1[4];=20
> const char rings2[6];
> const char rings3[8];
> const char rings4[10];
> const char rings5[12];
> const char rings6[14];
> const char rings7[16];
> const char rings8[18];
> const char rings9[20];
> const char rings10[22];
> const char rings11[4];
> const char rings12[6];
> const char rings13[8];
> const char rings14[10];
> const char rings15[12];
> const char rings16[14];
> const char rings17[16];
> const char rings18[18];
> const char rings19[20];
> const char rings20[22];
> }
> ~Rings(){} =20
>=20
> };
>=20
> int main()
> {
>=20
> while(true)
> {
> // main menu
> char square[10][3];
> int choice;
> cout << " THE TOWERS OF=20
> HANOI\n\n";
> cout << " =20
> **********************************************************\n\n";
> cout << " *MENU OF
> CHOICES*\n\n"; =20
> cout << " (1)About THE TOWERS
> OF HANOI\n\n";
> cout << " (2)Object of THE
> TOWERS OF HANOI\n\n"; =20
> cout << " (3)Rules of THE
> TOWRERS OF HANOI\n\n"; =20
> cout << " (4)Play\n\n"; =20
> =20
> cout << " (5)Exit\n\n\n"; =20
> =20
> cout << " Please enter your
> choice: "; =20
> cin >> choice; =20
> =20
> cout << "\n\n =20
> **********************************************************\n\n";
>=20
> switch(choice)
> {
> case 1: cout << " About
> THE TOWERS OF HANOI\n\n";
> cout << "The ancient puzzle of=20
> THE TOWERS OF
> HANOI involves three pegs with numerous\n";
> cout << "disks on the first peg. The disks
> are arranged in decreasing order of size\n\n";
> system("PAUSE");
> continue;
>=20
> case 2: cout << " Objective
> of THE TOWERS OF HANOI\n\n";
> cout << "The objective of this=20
> puzzle is to
> move all the disks to the last peg.\n\n";
> system("PAUSE");
> continue;
>=20
> case 3: cout << " Rules of
> THE TOWERS OF HANOI\n\n";
> cout << "The rules are that only=20
> one disk may
> be moved at a time and that a larger\n";
> cout << "disk may never be placed on a
> smaller disk.\n\n";
> system("PAUSE");
> continue;
>=20
> case 4: playGame(square);
> break;
>=20
> case 5: break;
>=20
> default: break;
>=20
> } //end switch
>=20
>=20
> break;
> }//end while(true)
>=20
> return 0;
>=20
> }//end main()
>=20
> void playGame(char square[10][3])
> {
> =09
> //menu
> int choiceRings;
> cout << " THE TOWERS OF
> HANOI\n";
> cout <<=20
> "*************************************************************
> **********************\n\n\n";
> cout << "\nHow many rings would you like there to be?
> (min. 4, max. 10): ";
>=20
> cin >> choiceRings;
> =09
> cout << "\n\n";
> //only choice for now
> if(choiceRings =3D=3D 4)
> {
> //gives each dimension on the board either an
> empty space or a ring
> Rings Aring;
> const char localRings1, localRings2,
> localRings3, localRings4;
> const char localRings5, localRings6,
> localRings7, localRings8;
> const char localRings9, localRings10,
> localRings11, localRings12;
> const char localRings13, localRings14,
> localRings15, localRings16;
> const char localRings17, localRings18,
> localRings19, localRings20;
> localRings1=3D Aring.rings1;
> localRings2=3D Aring.rings2;
> localRings3=3D Aring.rings3;
> localRings4=3D Aring.rings4;
> localRings5=3D Aring.rings5;
> localRings6=3D Aring.rings6; =20
> localRings7=3D Aring.rings7;
> localRings8=3D Aring.rings8;
> localRings9=3D Aring.rings9;
> localRings10=3D Aring.rings10;
> localRings11=3D Aring.rings11;
> localRings12=3D Aring.rings12;
> localRings13=3D Aring.rings13;
> localRings14=3D Aring.rings14;
> localRings15=3D Aring.rings15;
> localRings16=3D Aring.rings16;
> localRings17=3D Aring.rings17;
> localRings18=3D Aring.rings18;
> localRings19=3D Aring.rings19;
> localRings20=3D Aring.rings20;
> square[0][0]=3D localRings11;
> square[1][0]=3D localRings12;
> square[2][0]=3D localRings13;
> square[3][0]=3D localRings14;
> square[4][0]=3D localRings15;
> square[5][0]=3D localRings16;
> square[6][0]=3D localRings7;
> square[7][0]=3D localRings8;
> square[8][0]=3D localRings9;
> square[9][0]=3D localRings10;
> square[0][1]=3D localRings11;
> square[1][1]=3D localRings12;
> square[2][1]=3D localRings13;
> square[3][1]=3D localRings14;
> square[4][1]=3D localRings15;
> square[5][1]=3D localRings16;
> square[6][1]=3D localRings17;
> square[7][1]=3D localRings18;
> square[8][1]=3D localRings19;
> square[9][1]=3D localRings20;
> square[0][2]=3D localRings11;
> square[1][2]=3D localRings12;
> square[2][2]=3D localRings13;
> square[3][2]=3D localRings14;
> square[4][2]=3D localRings15;
> square[5][2]=3D localRings16;
> square[6][2]=3D localRings17;
> square[7][2]=3D localRings18;
> square[8][2]=3D localRings19;
> square[9][2]=3D localRings20;
>=20
> // All of the following if's show each mve that has to
> be made to win the game with four rings
> cout << "This is what the game board looks when no
> moves have been made, using four rings: \n";
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the first move to solving the game with
> four rings is made, it looks like this: \n";
> square[9][1]=3D localRings7;
> square[6][0]=3D localRings17;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the second move to solving the game is
> made, it looks like this: \n\n";
> square[9][2]=3D localRings8;
> square[7][0]=3D localRings18;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the third move to solving the game is
> made, it looks like this: \n\n";
> square[8][2]=3D localRings7;
> square[9][1]=3D localRings20;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the fourth move to solving the game is
> made, it should look like this: \n\n";
> square[9][1]=3D localRings9;
> square[8][0]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the fifth move to solving the game is
> made, it should look like this: \n\n";
> square[8][0]=3D localRings9;
> square[8][2]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the sixth move to solving the game, it
> should look like this: \n\n";
> square[8][1]=3D localRings8;
> square[9][2]=3D localRings20;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the seventh move to solving the game,
> it should look like this: \n\n";
> square[7][1]=3D localRings9;
> square[8][0]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the eighth move to solving the game, it
> should look like this: \n\n";
> square[9][2]=3D localRings10;
> square[9][0]=3D localRings20;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the ninth move to solving the game, it
> should look like this: \n\n";
> square[7][1]=3D localRings18;
> square[8][2]=3D localRings9;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the tenth move to solving the game, it
> should look like this: \n\n";
> square[8][1]=3D localRings19;
> square[9][0]=3D localRings8;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the eleventh move to solving the game,
> it should look like this: \n\n";
> square[8][2]=3D localRings19;
> square[8][0]=3D localRings9;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the twelfth move to solving the game,
> it should look like this: \n\n";
> square[9][1]=3D localRings20;
> square[8][2]=3D localRings9;
> gameBoard(square);
> =09
> =09
> =09
> =09
> system("PAUSE");
>=20
> cout << "After the thirteenth move to solving the
> game, it should look like this: \n\n";
> square[9][2]=3D localRings7;
> square[8][0]=3D localRings19;
> gameBoard(square);
>=20
> system("PAUSE");
>=20
> cout << "After the fourteenth move to solving the
> game, it should look like this: \n\n";
> square[7][2]=3D localRings8;
> square[9][0]=3D localRings20;
> gameBoard(square);
> =09
> =09
> system("PAUSE");
>=20
> cout << "After the fifteenth move to solving the game,
> it should look like this: \n\n";\
> square[6][2]=3D localRings7;
> square[9][1]=3D localRings20;
> gameBoard(square);
>=20
> cout << "That was the way a win with four rings should look\n\n";
> system("PAUSE");
>=20
> } //end if(choiceRings =3D=3D 4)
> }// end void playGame(char square[10][3])
>=20
> //game board
> void gameBoard(char square[10][3])
> {
> // gives each empty space on the board a dimension
> cout << " THE TOWERS OF
> HANOI\n";=20
> cout << "=20
> ______________________________________________________________
> _________\n";
> cout << "| | =20
> | |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[0][0]<<" | =20
> "<<square[0][1]<<" | =20
> "<<square[0][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[1][0]<<" | =20
> "<<square[1][1]<<" | =20
> "<<square[1][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[2][0]<<" | =20
> "<<square[2][1]<<" | "<<square[2][2]<<"=20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[3][0]<<" | =20
> "<<square[3][1]<<" | "<<square[3][2]<<" =20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[4][0]<<" | =20
> "<<square[4][1]<<" | "<<square[4][2]<<" =20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[5][0]<<" | =20
> "<<square[5][1]<<" | "<<square[5][2]<<" =20
> |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[6][0]<<" | =20
> "<<square[6][1]<<" | "<<square[6][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[7][0]<<" | =20
> "<<square[7][1]<<" | "<<square[7][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[8][0]<<" | "<<square[8][1]<<"
> | "<<square[8][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "| "<<square[9][0]<<" | "<<square[9][1]<<" |=20
> "<<square[9][2]<<" |\n";
> cout << "| | | | =20
> | | |\n";
> cout << "=20
-----------------------------------------------------------------------\
n";
> } //error message: parse error at end of input. ponits
> to this line????
>=20
> =3D=3D=3D=3D=3D
> Julio
>=20
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with=20
> Yahoo! Messenger http://phonecard.yahoo.com/
>=20
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|
|
From: Julio L. <ju2...@ya...> - 2001-07-21 22:42:04
|
This program has no other problems(ignoring the fact
that I am assigning rings to the dimensions of the
board) excpet that when I try to compile it, it says
parse error at end of input, and I dont see it.
#include <iostream.h>
#include <stdlib.h>
#include "Tower Ring Class.hpp"
//function prototypes
void gameBoard(char square[10][3]);
void playGame(char square[10][3]);
//This class creates te rings that will be placed on
the gameBoard
class Rings
{
Rings():
rings1[4]("777"),
rings2[6]("77777"),
rings3[8]("7777777"),
rings4[10]("777777777"),
rings5[12]("77777777777"),
rings6[14]("7777777777777"),
rings7[16]("777777777777777"),
rings8[18]("77777777777777777"),
rings9[20]("7777777777777777777"),
rings10[22]("777777777777777777777"),
rings11[4](" "),
rings12[6](" "),
rings13[8](" "),
rings14[10](" "),
rings15[12](" "),
rings16[14]{" "),
rings17[16](" "),
rings18[18](" "),
rings19[20](" "),
rings20[22](" ")
{
const char rings1[4];
const char rings2[6];
const char rings3[8];
const char rings4[10];
const char rings5[12];
const char rings6[14];
const char rings7[16];
const char rings8[18];
const char rings9[20];
const char rings10[22];
const char rings11[4];
const char rings12[6];
const char rings13[8];
const char rings14[10];
const char rings15[12];
const char rings16[14];
const char rings17[16];
const char rings18[18];
const char rings19[20];
const char rings20[22];
}
~Rings(){}
};
int main()
{
while(true)
{
// main menu
char square[10][3];
int choice;
cout << " THE TOWERS OF
HANOI\n\n";
cout << "
**********************************************************\n\n";
cout << " *MENU OF
CHOICES*\n\n";
cout << " (1)About THE TOWERS
OF HANOI\n\n";
cout << " (2)Object of THE
TOWERS OF HANOI\n\n";
cout << " (3)Rules of THE
TOWRERS OF HANOI\n\n";
cout << " (4)Play\n\n";
cout << " (5)Exit\n\n\n";
cout << " Please enter your
choice: ";
cin >> choice;
cout << "\n\n
**********************************************************\n\n";
switch(choice)
{
case 1: cout << " About
THE TOWERS OF HANOI\n\n";
cout << "The ancient puzzle of THE TOWERS OF
HANOI involves three pegs with numerous\n";
cout << "disks on the first peg. The disks
are arranged in decreasing order of size\n\n";
system("PAUSE");
continue;
case 2: cout << " Objective
of THE TOWERS OF HANOI\n\n";
cout << "The objective of this puzzle is to
move all the disks to the last peg.\n\n";
system("PAUSE");
continue;
case 3: cout << " Rules of
THE TOWERS OF HANOI\n\n";
cout << "The rules are that only one disk may
be moved at a time and that a larger\n";
cout << "disk may never be placed on a
smaller disk.\n\n";
system("PAUSE");
continue;
case 4: playGame(square);
break;
case 5: break;
default: break;
} //end switch
break;
}//end while(true)
return 0;
}//end main()
void playGame(char square[10][3])
{
//menu
int choiceRings;
cout << " THE TOWERS OF
HANOI\n";
cout <<
"***********************************************************************************\n\n\n";
cout << "\nHow many rings would you like there to be?
(min. 4, max. 10): ";
cin >> choiceRings;
cout << "\n\n";
//only choice for now
if(choiceRings == 4)
{
//gives each dimension on the board either an
empty space or a ring
Rings Aring;
const char localRings1, localRings2,
localRings3, localRings4;
const char localRings5, localRings6,
localRings7, localRings8;
const char localRings9, localRings10,
localRings11, localRings12;
const char localRings13, localRings14,
localRings15, localRings16;
const char localRings17, localRings18,
localRings19, localRings20;
localRings1= Aring.rings1;
localRings2= Aring.rings2;
localRings3= Aring.rings3;
localRings4= Aring.rings4;
localRings5= Aring.rings5;
localRings6= Aring.rings6;
localRings7= Aring.rings7;
localRings8= Aring.rings8;
localRings9= Aring.rings9;
localRings10= Aring.rings10;
localRings11= Aring.rings11;
localRings12= Aring.rings12;
localRings13= Aring.rings13;
localRings14= Aring.rings14;
localRings15= Aring.rings15;
localRings16= Aring.rings16;
localRings17= Aring.rings17;
localRings18= Aring.rings18;
localRings19= Aring.rings19;
localRings20= Aring.rings20;
square[0][0]= localRings11;
square[1][0]= localRings12;
square[2][0]= localRings13;
square[3][0]= localRings14;
square[4][0]= localRings15;
square[5][0]= localRings16;
square[6][0]= localRings7;
square[7][0]= localRings8;
square[8][0]= localRings9;
square[9][0]= localRings10;
square[0][1]= localRings11;
square[1][1]= localRings12;
square[2][1]= localRings13;
square[3][1]= localRings14;
square[4][1]= localRings15;
square[5][1]= localRings16;
square[6][1]= localRings17;
square[7][1]= localRings18;
square[8][1]= localRings19;
square[9][1]= localRings20;
square[0][2]= localRings11;
square[1][2]= localRings12;
square[2][2]= localRings13;
square[3][2]= localRings14;
square[4][2]= localRings15;
square[5][2]= localRings16;
square[6][2]= localRings17;
square[7][2]= localRings18;
square[8][2]= localRings19;
square[9][2]= localRings20;
// All of the following if's show each mve that has to
be made to win the game with four rings
cout << "This is what the game board looks when no
moves have been made, using four rings: \n";
gameBoard(square);
system("PAUSE");
cout << "After the first move to solving the game with
four rings is made, it looks like this: \n";
square[9][1]= localRings7;
square[6][0]= localRings17;
gameBoard(square);
system("PAUSE");
cout << "After the second move to solving the game is
made, it looks like this: \n\n";
square[9][2]= localRings8;
square[7][0]= localRings18;
gameBoard(square);
system("PAUSE");
cout << "After the third move to solving the game is
made, it looks like this: \n\n";
square[8][2]= localRings7;
square[9][1]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the fourth move to solving the game is
made, it should look like this: \n\n";
square[9][1]= localRings9;
square[8][0]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the fifth move to solving the game is
made, it should look like this: \n\n";
square[8][0]= localRings9;
square[8][2]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the sixth move to solving the game, it
should look like this: \n\n";
square[8][1]= localRings8;
square[9][2]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the seventh move to solving the game,
it should look like this: \n\n";
square[7][1]= localRings9;
square[8][0]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the eighth move to solving the game, it
should look like this: \n\n";
square[9][2]= localRings10;
square[9][0]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the ninth move to solving the game, it
should look like this: \n\n";
square[7][1]= localRings18;
square[8][2]= localRings9;
gameBoard(square);
system("PAUSE");
cout << "After the tenth move to solving the game, it
should look like this: \n\n";
square[8][1]= localRings19;
square[9][0]= localRings8;
gameBoard(square);
system("PAUSE");
cout << "After the eleventh move to solving the game,
it should look like this: \n\n";
square[8][2]= localRings19;
square[8][0]= localRings9;
gameBoard(square);
system("PAUSE");
cout << "After the twelfth move to solving the game,
it should look like this: \n\n";
square[9][1]= localRings20;
square[8][2]= localRings9;
gameBoard(square);
system("PAUSE");
cout << "After the thirteenth move to solving the
game, it should look like this: \n\n";
square[9][2]= localRings7;
square[8][0]= localRings19;
gameBoard(square);
system("PAUSE");
cout << "After the fourteenth move to solving the
game, it should look like this: \n\n";
square[7][2]= localRings8;
square[9][0]= localRings20;
gameBoard(square);
system("PAUSE");
cout << "After the fifteenth move to solving the game,
it should look like this: \n\n";\
square[6][2]= localRings7;
square[9][1]= localRings20;
gameBoard(square);
cout << "That was the way a win with four rings should
look\n\n";
system("PAUSE");
} //end if(choiceRings == 4)
}// end void playGame(char square[10][3])
//game board
void gameBoard(char square[10][3])
{
// gives each empty space on the board a dimension
cout << " THE TOWERS OF
HANOI\n";
cout << "
_______________________________________________________________________\n";
cout << "| |
| |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[0][0]<<" |
"<<square[0][1]<<" |
"<<square[0][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[1][0]<<" |
"<<square[1][1]<<" |
"<<square[1][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[2][0]<<" |
"<<square[2][1]<<" | "<<square[2][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[3][0]<<" |
"<<square[3][1]<<" | "<<square[3][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[4][0]<<" |
"<<square[4][1]<<" | "<<square[4][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[5][0]<<" |
"<<square[5][1]<<" | "<<square[5][2]<<"
|\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[6][0]<<" |
"<<square[6][1]<<" | "<<square[6][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[7][0]<<" |
"<<square[7][1]<<" | "<<square[7][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[8][0]<<" | "<<square[8][1]<<"
| "<<square[8][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "| "<<square[9][0]<<" | "<<square[9][1]<<" |
"<<square[9][2]<<" |\n";
cout << "| | | |
| | |\n";
cout << "
-----------------------------------------------------------------------\n";
} //error message: parse error at end of input. ponits
to this line????
=====
Julio
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
|
|
From: <Tre...@ao...> - 2001-07-21 17:11:14
|
To me, this code looks fine. When I execute the program it should give me a
reverse of the first pattern when I choose pattern2, but it gives me the same
output as pattern1.
#include<iostream>
using namespace std;
//*****function prototypes
void getPattern1(int &, int &);
void getPattern2(int &, int &);
int main()
{
int pattern = 0;
int lines = 0;
int stars = 0;
cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;
cin >> pattern;
if (pattern == 1)
{
getPattern1(lines, stars);
}
else
{
getPattern1(lines, stars);
}
return 0;
}
//*****functions*****
void getPattern1(int &lines, int &stars)
{
lines = 9;
while (lines > 0)
{
stars = lines;
while (stars > 0)
{
cout << '*';
stars--;
}
cout << '\n';
lines--;
}
}
void getPattern2(int &lines, int &stars)
{
lines = 1;
while (lines < 10)
{
stars = lines;
while (stars < 10)
{
cout << '*';
stars++;
}
cout << '\n';
lines++;
}
}
|
|
From: Ioannis V. <no...@ya...> - 2001-07-21 17:09:25
|
For console programs you compile your program and then you either execute it from a console window or from start->run. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of barbrara > Sent: Saturday, July 21, 2001 5:36 PM > To: dev...@li... > Subject: [Dev-C++] Help for a dummy!!!! > > > I've downloaded DEV C++. > I've started to programme and I'm quite helpless. > I can't see the window I generally have in Turbo-C when I do > ALT F5 or Window/userscreen. You know I'm quite helpless and > I have just few notions of programming. Besides I'm not > english mother-tongue (I'm italian). Please, if someone > may.... explain me in a really simple way step by step. > > Thanks. > > Barbara. > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: barbrara <an...@in...> - 2001-07-21 15:25:36
|
I've downloaded DEV C++. I've started to programme and I'm quite helpless. I can't see the window I generally have in Turbo-C when I do ALT F5 or Window/userscreen. You know I'm quite helpless and I have just few notions of programming. Besides I'm not english mother-tongue (I'm italian). Please, if someone may.... explain me in a really simple way step by step. Thanks. Barbara. |
|
From: Ioannis V. <no...@ya...> - 2001-07-21 14:34:25
|
You have " " after x+y in the cout phrase. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf Of Jarred > Sent: Saturday, July 21, 2001 4:19 PM > To: dev...@li... > Subject: [Dev-C++] why wont this compile >=20 >=20 > I'm just trying to learn this stuff and for some reason this=20 > code won't compile. It is ment to be c++. I wood appreciate=20 > any answers or help. Below is the complete code. >=20 > #include <iostream.h> > #include <stdlib.h> >=20 > int main() > { > int x =3D 5; > int y =3D 7; > cout "\n"; > cout << x + y " " << x*y; > cout "\n"; >=20 >=20 > system("PAUSE"); > return 0; > } >=20 >=20 > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com >=20 >=20 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |
|
From: Elie J. <el...@dn...> - 2001-07-21 14:28:05
|
Jarred,
There are a few simple syntax mistakes you've done - here is a corrected
version (assuming that your system call is actually working fine) :
#include <iostream.h>
#include <stdlib.h>
int main() {
int x = 5;
int y = 7;
cout << "\n";
cout << x + y;
cout << "\n";
// or you could have : cout << "\n" << x + y " " << "\n";
// which is very much like : cout << endl << x + y " " << endl;
system("PAUSE");
return 0;
}
|
|
From: Jay S. <mys...@op...> - 2001-07-21 14:26:08
|
You need to read a basic manual.
#include <iostream.h>
#include <stdlib.h>
int main()
{
int x = 5;
int y = 7;
cout<< "\n";
cout << x +y<< " " << x*y;
cout <<"\n";
system("PAUSE");
return 0;
}
Is what you want to use. You left the <<'s off the first and third cout statements, and in the second cout statement you want to use a << before the " " as well.
Techneaux
----- Original Message -----
From: Jarred
To: dev...@li...
Sent: Saturday, July 21, 2001 10:19 AM
Subject: [Dev-C++] why wont this compile
I'm just trying to learn this stuff and for some reason this code won't
compile. It is ment to be c++. I wood appreciate any answers or help. Below
is the complete code.
#include <iostream.h>
#include <stdlib.h>
int main()
{
int x = 5;
int y = 7;
cout "\n";
cout << x + y " " << x*y;
cout "\n";
system("PAUSE");
return 0;
}
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Jarred <sto...@ya...> - 2001-07-21 14:20:46
|
I'm just trying to learn this stuff and for some reason this code won't
compile. It is ment to be c++. I wood appreciate any answers or help. Below
is the complete code.
#include <iostream.h>
#include <stdlib.h>
int main()
{
int x = 5;
int y = 7;
cout "\n";
cout << x + y " " << x*y;
cout "\n";
system("PAUSE");
return 0;
}
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|
|
From: Jarred <sto...@ya...> - 2001-07-21 12:26:20
|
Could someone please tell me how the visual debugger works. I am blind and so want to know if it desplays messages in text or graphics. I'm not sure if it is worth the download and am trying to decide if it is worth the download. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
|
From: Vassili <v.v...@bt...> - 2001-07-21 08:32:08
|
You can find the latest STL at: http://www.sgi.com/tech/stl/ best of luck Vas. ----- Original Message ----- From: "Ioannis Vranos" <no...@ya...> To: <dev...@li...> Sent: Friday, July 20, 2001 1:41 PM Subject: RE: [Dev-C++] [Dev C++] istreambuf_iterator not present in Dev-C++ ? > Compiler was released at 24 October 1999. Be patient to wait for the new > gcc 3.0 port for windows... > > > Ioannis > > * Ioannis Vranos > * Programming pages: http://www.noicys.f2s.com > * Alternative URL: http://run.to/noicys > > > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Jeethu Rao > > Sent: Friday, July 20, 2001 10:57 AM > > To: Dev CPP Mailing List > > Subject: [Dev-C++] [Dev C++] istreambuf_iterator not present > > in Dev-C++ ? > > > > > > Hi, > > I'm just learning STL. I tried running an example > > from Bruce Eckel's book "Thinking in C++". > > > > This particular example uses istreambuf_iterator . > > When I change all occurance of istreambuf_iterator to > > istream_iterator, the code works. > > > > Is the version of STL which comes with Dev-C++ old ? > > I'm using Dev-C++ 4.00 Do I need to upgrade ? > > > > Please Suggest > > > > Jeethu Rao > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Vassili <v.v...@bt...> - 2001-07-21 08:30:03
|
This is the way I done it for my computeach course:
after getting the string I passed it to this function
unsigned calc_hash(char *reg)
{
char first_val, second_val[4];
int count;
unsigned value;
first_val =3D *reg; /* Store first character of regestration */
reg++;
/* Get the next three characters */
for(count =3D 0; count <=3D 2; count++, reg++)
second_val[count] =3D *reg;
second_val[3] =3D '\0'; /* Add null character */
value =3D first_val - 'A'; /* Subtract 'A' from the first character =
*/
value *=3D 1000; /* Multiply by number of records for each =
alpha character */
value +=3D atoi(second_val); /* Convert second_val to integer and =
add to value */
return value; /* return the hash */
}
hope this helps
Vas.
----- Original Message -----=20
From: Kei...@ao...=20
To: ":dev-cp"@lists.sourceforge.net=20
Sent: Friday, July 20, 2001 8:32 PM
Subject: [Dev-C++] Re C++
I am trying to write a program for vehicle registration ( a project =
for my=20
course in C programming) which takes a string of 1letter,3 digits, 3 =
letters(=20
UK number plate) using the 1st letter - 'A' * 1000 and the 3 digits =
to=20
produce a record number to locate the vehicle registration record. =
The file=20
is binary.=20
How can I take the registration number and convert it to the record =
number.=20
Thanks=20
Keith Lavington=20
|
|
From: Ken T. <ad...@nw...> - 2001-07-21 04:54:21
|
Looked at the subscription site but there were no instructions on unsubscribing. And, to top it off with, I'v forgotten the password and username I used to subscribe with. -- Ken Thompson Payette, Idaho. ad...@nw... http://www.nwaa.com |
|
From: lonestar36 <lon...@go...> - 2001-07-21 00:45:16
|
You might try to use strtok
char string[24] = "4321$$$abcd$$$ddef";
char *p;
p = strtok(string,"$$$");
printf("%s", p);
p = strtok(NULL."$$$");
printf("%s", p);
----- Original Message -----
From: "Ian Weston" <lak...@ho...>
To: <dev...@li...>
Sent: Friday, July 20, 2001 4:13 PM
Subject: [Dev-C++] searching text
> hi all. im writing a program at the moment which stores peoples names and
> address to a text file. it saves it all as one long sting and seperating
> each feild is $$$. i need to know how to search the text so that i can
find
> where each feild begins.
>
> please could somebody help.
>
> thanks, ian.
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Ioannis V. <no...@ya...> - 2001-07-20 22:18:04
|
I guess C. strstr() of string.h . Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Ian Weston > Sent: Friday, July 20, 2001 11:13 PM > To: dev...@li... > Subject: [Dev-C++] searching text > > > hi all. im writing a program at the moment which stores > peoples names and > address to a text file. it saves it all as one long sting and > seperating > each feild is $$$. i need to know how to search the text so > that i can find > where each feild begins. > > please could somebody help. > > thanks, ian. > > _________________________________________________________________ > Get your FREE download of MSN Explorer at > http://explorer.msn.com/intl.asp > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Ian W. <lak...@ho...> - 2001-07-20 21:13:36
|
hi all. im writing a program at the moment which stores peoples names and address to a text file. it saves it all as one long sting and seperating each feild is $$$. i need to know how to search the text so that i can find where each feild begins. please could somebody help. thanks, ian. _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
|
From: Ioannis V. <no...@ya...> - 2001-07-20 20:53:04
|
The problem is that you forgot those parenthesis () in the getRoundedSalary() 2 times. I send you the code attached for checking. Also your code is not ANSI C++ (probably an outdated book). Friendly, Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Julio Lajara > Sent: Friday, July 20, 2001 8:31 PM > To: dev...@li... > Subject: [Dev-C++] I have a problem with class method, need > help....... > > > I am having problems getting getRoundedSalary to > return salary(rounded to the nearest 1,000). When I > try to get it to output employ->getRoundedSalary() to > the screen later in the code it says it is of unknown > type and wont let it be displayed to screen. Can > anyone suggest how I should rewrite getRoundedSalary > so I can get it to output salary rounded to the > nearest 1,000? Here is my code : > > #include <iostream.h> > #include <stdlib.h> > > class Employee > { > public: > > unsigned short int getAge(){return age;} > void setAge(int setAgeTo){ age =setAgeTo;} > unsigned short int getYearsOfService(){return > yearsOfService;} > void setYearsOfService(int > setYearsOfServiceTo){yearsOfService > =setYearsOfServiceTo;} > unsigned long int getSalary(){return salary;} > void setSalary(long int setSalaryTo){salary > =setSalaryTo;} > float getRoundedSalary() > { > return (salary+500)/1000; > } > private: > unsigned short int age; > unsigned short int yearsOfService; > unsigned long int salary; > }; > > int main() > { > unsigned long int emplOneAge, emplTwoAge, emplOneServ, > emplTwoServ, emplOneSal, emplTwoSal; > cout << "How old is employee 1?: "; > cin >> emplOneAge; > Employee *employOne= new Employee; > employOne->setAge(emplOneAge); > > cout << "\n\nFor how many years has employee 1 been > working for you?: "; > cin >> emplOneServ; > employOne->setYearsOfService(emplOneServ); > > cout << "\n\nHow much money does employee 1 make?: "; > cin >> emplOneSal; > employOne->setSalary(emplOneSal); > > cout << "\n\nHow old is employee 2?: "; > cin >> emplTwoAge; > Employee *employTwo= new Employee; > employTwo->setAge(emplTwoAge); > > cout << "\n\nFor how many years has employee 2 been > working for you?: "; > cin >> emplTwoServ; > employTwo->setYearsOfService(emplTwoServ); > > cout << "\n\nHow much money does employee 2 make?: "; > cin >> emplTwoSal; > employTwo->setSalary(emplTwoSal); > cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; > > while(true) > { > unsigned short int menuChoice; > cout << "\t\t\t****************************\n"; > cout << "\t\t\t* Employee Directory *\n"; > cout << "\t\t\t* Choices: *\n"; > cout << "\t\t\t* *\n"; > cout << "\t\t\t* 1)Employee 1 Info. *\n"; > cout << "\t\t\t* 2)Employee 2 Info. *\n"; > cout << "\t\t\t* 3)Exit *\n"; > cout << "\t\t\t****************************\n"; > cout << "\t\t\t Enter Choice: "; > cin >> menuChoice; > cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; > switch(menuChoice) > { > case 1: cout << "Current Information on Employee > 1:\n\n"; > cout << "Age: " << employOne->getAge() << endl; > cout << "Years of Service: " << > employOne->getYearsOfService() << endl; > cout << "Salary: " << employOne->getSalary() << endl; > cout << "Salary (To nearest $1,000): " << > employOne->getRoundedSalary << endl; > > system("PAUSE"); > cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; > continue; > case 2: cout << "Current Information on Employee > 2:\n\n"; > cout << "Age: " << employTwo->getAge() << endl; > cout << "Years of Service: " << > employTwo->getYearsOfService() << endl; > cout << "Salary: " << employTwo->getSalary() << endl; > cout << "Salary (To nearest $1,000): " << > employTwo->getRoundedSalary << endl; > > system("PAUSE"); > cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; > continue; > case 3: break; > default: continue; > } //end switch(menuChoice) > break; > }//end while(true) > > delete employOne; > delete employTwo; > } //end main() > > > ===== > Julio > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: <Kei...@ao...> - 2001-07-20 19:32:23
|
I am trying to write a program for vehicle registration ( a project for my course in C programming) which takes a string of 1letter,3 digits, 3 letters( UK number plate) using the 1st letter - 'A' * 1000 and the 3 digits to produce a record number to locate the vehicle registration record. The file is binary. How can I take the registration number and convert it to the record number. Thanks Keith Lavington |
|
From: Schedler, K. <Kur...@hi...> - 2001-07-20 18:51:21
|
You are using employOne->getRoundedSalary instead of
employOne->getRoundedSalary().
-----Original Message-----
From: Julio Lajara [mailto:ju2...@ya...]
Sent: Friday, July 20, 2001 11:31 AM
To: dev...@li...
Subject: [Dev-C++] I have a problem with class method, need help.......
I am having problems getting getRoundedSalary to
return salary(rounded to the nearest 1,000). When I
try to get it to output employ->getRoundedSalary() to
the screen later in the code it says it is of unknown
type and wont let it be displayed to screen. Can
anyone suggest how I should rewrite getRoundedSalary
so I can get it to output salary rounded to the
nearest 1,000? Here is my code :
#include <iostream.h>
#include <stdlib.h>
class Employee
{
public:
unsigned short int getAge(){return age;}
void setAge(int setAgeTo){ age =setAgeTo;}
unsigned short int getYearsOfService(){return
yearsOfService;}
void setYearsOfService(int
setYearsOfServiceTo){yearsOfService
=setYearsOfServiceTo;}
unsigned long int getSalary(){return salary;}
void setSalary(long int setSalaryTo){salary
=setSalaryTo;}
float getRoundedSalary()
{
return (salary+500)/1000;
}
private:
unsigned short int age;
unsigned short int yearsOfService;
unsigned long int salary;
};
int main()
{
unsigned long int emplOneAge, emplTwoAge, emplOneServ,
emplTwoServ, emplOneSal, emplTwoSal;
cout << "How old is employee 1?: ";
cin >> emplOneAge;
Employee *employOne= new Employee;
employOne->setAge(emplOneAge);
cout << "\n\nFor how many years has employee 1 been
working for you?: ";
cin >> emplOneServ;
employOne->setYearsOfService(emplOneServ);
cout << "\n\nHow much money does employee 1 make?: ";
cin >> emplOneSal;
employOne->setSalary(emplOneSal);
cout << "\n\nHow old is employee 2?: ";
cin >> emplTwoAge;
Employee *employTwo= new Employee;
employTwo->setAge(emplTwoAge);
cout << "\n\nFor how many years has employee 2 been
working for you?: ";
cin >> emplTwoServ;
employTwo->setYearsOfService(emplTwoServ);
cout << "\n\nHow much money does employee 2 make?: ";
cin >> emplTwoSal;
employTwo->setSalary(emplTwoSal);
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
while(true)
{
unsigned short int menuChoice;
cout << "\t\t\t****************************\n";
cout << "\t\t\t* Employee Directory *\n";
cout << "\t\t\t* Choices: *\n";
cout << "\t\t\t* *\n";
cout << "\t\t\t* 1)Employee 1 Info. *\n";
cout << "\t\t\t* 2)Employee 2 Info. *\n";
cout << "\t\t\t* 3)Exit *\n";
cout << "\t\t\t****************************\n";
cout << "\t\t\t Enter Choice: ";
cin >> menuChoice;
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
switch(menuChoice)
{
case 1: cout << "Current Information on Employee
1:\n\n";
cout << "Age: " << employOne->getAge() << endl;
cout << "Years of Service: " <<
employOne->getYearsOfService() << endl;
cout << "Salary: " << employOne->getSalary() << endl;
cout << "Salary (To nearest $1,000): " <<
employOne->getRoundedSalary << endl;
system("PAUSE");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
continue;
case 2: cout << "Current Information on Employee
2:\n\n";
cout << "Age: " << employTwo->getAge() << endl;
cout << "Years of Service: " <<
employTwo->getYearsOfService() << endl;
cout << "Salary: " << employTwo->getSalary() << endl;
cout << "Salary (To nearest $1,000): " <<
employTwo->getRoundedSalary << endl;
system("PAUSE");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
continue;
case 3: break;
default: continue;
} //end switch(menuChoice)
break;
}//end while(true)
delete employOne;
delete employTwo;
} //end main()
=====
Julio
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
"The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message
and its attachments could have been infected during transmission. By
reading the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. The sender's employer is not liable for any loss or damage
arising in any way from this message or its attachments."
|
|
From: Julio L. <ju2...@ya...> - 2001-07-20 18:30:39
|
I am having problems getting getRoundedSalary to
return salary(rounded to the nearest 1,000). When I
try to get it to output employ->getRoundedSalary() to
the screen later in the code it says it is of unknown
type and wont let it be displayed to screen. Can
anyone suggest how I should rewrite getRoundedSalary
so I can get it to output salary rounded to the
nearest 1,000? Here is my code :
#include <iostream.h>
#include <stdlib.h>
class Employee
{
public:
unsigned short int getAge(){return age;}
void setAge(int setAgeTo){ age =setAgeTo;}
unsigned short int getYearsOfService(){return
yearsOfService;}
void setYearsOfService(int
setYearsOfServiceTo){yearsOfService
=setYearsOfServiceTo;}
unsigned long int getSalary(){return salary;}
void setSalary(long int setSalaryTo){salary
=setSalaryTo;}
float getRoundedSalary()
{
return (salary+500)/1000;
}
private:
unsigned short int age;
unsigned short int yearsOfService;
unsigned long int salary;
};
int main()
{
unsigned long int emplOneAge, emplTwoAge, emplOneServ,
emplTwoServ, emplOneSal, emplTwoSal;
cout << "How old is employee 1?: ";
cin >> emplOneAge;
Employee *employOne= new Employee;
employOne->setAge(emplOneAge);
cout << "\n\nFor how many years has employee 1 been
working for you?: ";
cin >> emplOneServ;
employOne->setYearsOfService(emplOneServ);
cout << "\n\nHow much money does employee 1 make?: ";
cin >> emplOneSal;
employOne->setSalary(emplOneSal);
cout << "\n\nHow old is employee 2?: ";
cin >> emplTwoAge;
Employee *employTwo= new Employee;
employTwo->setAge(emplTwoAge);
cout << "\n\nFor how many years has employee 2 been
working for you?: ";
cin >> emplTwoServ;
employTwo->setYearsOfService(emplTwoServ);
cout << "\n\nHow much money does employee 2 make?: ";
cin >> emplTwoSal;
employTwo->setSalary(emplTwoSal);
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
while(true)
{
unsigned short int menuChoice;
cout << "\t\t\t****************************\n";
cout << "\t\t\t* Employee Directory *\n";
cout << "\t\t\t* Choices: *\n";
cout << "\t\t\t* *\n";
cout << "\t\t\t* 1)Employee 1 Info. *\n";
cout << "\t\t\t* 2)Employee 2 Info. *\n";
cout << "\t\t\t* 3)Exit *\n";
cout << "\t\t\t****************************\n";
cout << "\t\t\t Enter Choice: ";
cin >> menuChoice;
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
switch(menuChoice)
{
case 1: cout << "Current Information on Employee
1:\n\n";
cout << "Age: " << employOne->getAge() << endl;
cout << "Years of Service: " <<
employOne->getYearsOfService() << endl;
cout << "Salary: " << employOne->getSalary() << endl;
cout << "Salary (To nearest $1,000): " <<
employOne->getRoundedSalary << endl;
system("PAUSE");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
continue;
case 2: cout << "Current Information on Employee
2:\n\n";
cout << "Age: " << employTwo->getAge() << endl;
cout << "Years of Service: " <<
employTwo->getYearsOfService() << endl;
cout << "Salary: " << employTwo->getSalary() << endl;
cout << "Salary (To nearest $1,000): " <<
employTwo->getRoundedSalary << endl;
system("PAUSE");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
continue;
case 3: break;
default: continue;
} //end switch(menuChoice)
break;
}//end while(true)
delete employOne;
delete employTwo;
} //end main()
=====
Julio
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
|
|
From: Schedler, K. <Kur...@hi...> - 2001-07-20 18:16:35
|
I'll just give you a hint this time instead of writing the code for you. If
you want to reverse the pattern,
try counting 1, 2, 3, ... 9 instead of 9, 8, 7, ... 1. I'll also tell you
that I only had to change three lines
in my original code to make it print out the pattern in reverse, and those
changes were very insignificant.
You keep hitting infinite loops because you put a condition in the while
clause (stars < 10), but you never
change the value you're testing within the loop, so the condition will never
become false. Notice my
original while loop:
while (stars > 0)
{
putchar('*');
stars--;
}
stars starts out at some value greater than zero (since we're setting it
equal to lines) and each time
through the loop, it decreases by one (stars--, the minus-minus is the
decrement operator). Without
decrementing stars, it stays the same greater-than-zero value and the while
condition will be true
forever. Let's look at your code:
lines = 9;
stars = 1;
while (lines > 0)
{
putchar('*');
stars++;
while (stars < 10)
{
putchar('\n');
lines--;
}
}
The first time we go through the loop, lines = 9 and stars = 1. We output
one asterisk and increment
stars to 2. We enter the nested loop and 2 is less than 10 so we output a
newline character and
decrement lines to 8. Then since stars is still equal to 2, we do the loop
again. Another
newline is output and lines is decremented to 7. On and on we go,
outputting newlines and
decrementing lines by one.
And as Ioannos said, you can use cout << '*' instead of putchar('*').
-----Original Message-----
From: Tre...@ao... [mailto:Tre...@ao...]
Sent: Friday, July 20, 2001 10:46 AM
To: dev...@li...
Subject: Re: [Dev-C++] nested loop
Thank you for your help :) I am now trying to reverse the pattern and I am
getting an infinite loop.....can you see what is wrong.....it looks fine to
me.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int pattern = 0;
int lines = 0;
int stars;
cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;
cin >> pattern;
if (pattern == 1)
{
lines = 9;
while (lines > 0)
{
stars = lines;
while (stars > 0)
{
putchar('*');
stars--;
}
putchar('\n');
lines--;
}
}
else if (pattern == 2)
{
lines = 9;
stars = 1;
while (lines > 0)
{
putchar('*');
stars++;
while (stars < 10)
{
putchar('\n');
lines--;
}
}
} //end if
return 0;
}
"The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message
and its attachments could have been infected during transmission. By
reading the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. The sender's employer is not liable for any loss or damage
arising in any way from this message or its attachments."
|
|
From: Ioannis V. <no...@ya...> - 2001-07-20 17:59:04
|
putchar() is defined in <cstdio> but don't use putchar, use cout<<'*'; There are some logical errors but i thik you can vfind them. =20 =20 Ioannis =20 * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com <http://www.noicys.f2s.com/>=20 * Alternative URL: http://run.to/noicys -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Tre...@ao... Sent: Friday, July 20, 2001 7:46 PM To: dev...@li... Subject: Re: [Dev-C++] nested loop Thank you for your help :) I am now trying to reverse the pattern and I am=20 getting an infinite loop.....can you see what is wrong.....it looks fine to=20 me.=20 #include<iostream>=20 #include<string>=20 using namespace std;=20 int main()=20 {=20 int pattern =3D 0;=20 int lines =3D 0;=20 int stars;=20 cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;=20 cin >> pattern;=20 if (pattern =3D=3D 1)=20 {=20 lines =3D 9;=20 while (lines > 0)=20 {=20 stars =3D lines;=20 while (stars > 0)=20 {=20 putchar('*');=20 stars--;=20 }=20 putchar('\n');=20 lines--;=20 }=20 =20 }=20 else if (pattern =3D=3D 2)=20 {=20 lines =3D 9;=20 stars =3D 1;=20 while (lines > 0)=20 {=20 putchar('*');=20 stars++;=20 =20 while (stars < 10)=20 {=20 putchar('\n');=20 lines--;=20 }=20 =20 }=20 =20 } //end if=20 return 0;=20 }=20 |