PokeGym Home PagePokeGym ForumsPokeGym Members BlogsPokeGym Image GalleryPokeGym Researching TowerPokeGym TCG SearchPokeGym Tournment Decklist CreatorPokemon Official Rulings Compendium

Go Back   The PokeGym > Other Forums > Random Topic Center


Reply
 
Thread Tools Display Modes
Old 12/01/2009, 01:26 PM   #1
legotack
 
legotack's Avatar
 
Send a message via AIM to legotack
C++ help

Please read before posting:
Do not give me the complete answer, just try to start me on the right track.

Here is my assignment: Make a program that counts from one to a trillion (it's okay if I just start out to 100 or something and get bigger) AND says each number in words.

Here is my program so far:

#include <iostream>
#include <string>

using namespace ***;

string onesPlaceWrite(int, int);
string tensPlaceWrite(int, int);
string hundredsPlaceWrite(int);

int main()
{
bool writeTens = false;
bool writeHundreds = false;
int onesPlaceNumberWrite;

for (int hundredsPlaceNumber = 0; hundredsPlaceNumber <= 9; hundredsPlaceNumber = hundredsPlaceNumber + 1)
{
if (hundredsPlaceNumber > 0)
{
writeHundreds = true;
}

for (int tensPlaceNumber = 0; tensPlaceNumber <= 9; tensPlaceNumber = tensPlaceNumber)
{
for (int onesPlaceNumber = 1; onesPlaceNumber <= 10; onesPlaceNumber = onesPlaceNumber + 1)
{
onesPlaceNumberWrite = onesPlaceNumber;

if (onesPlaceNumber == 10)
{
onesPlaceNumberWrite = 0;
tensPlaceNumber = tensPlaceNumber + 1;
writeTens = true;
}
if (writeHundreds == true)
{
cout<<hundredsPlaceNumber;
}
if (writeTens == true)
{
cout<<tensPlaceNumber;
}



cout<<onesPlaceNumberWrite<<" is "<<hundredsPlaceWrite(hundredsPlaceNumber)<<tensPl aceWrite(tensPlaceNumber, onesPlaceNumberWrite)<<onesPlaceWrite(onesPlaceNum ber, tensPlaceNumber)<<endl;
}
}




}
}

string onesPlaceWrite(int onesPlaceNumber, int tensPlaceNumber)
{
string onesPlaceText;

if (onesPlaceNumber == 0)
{
onesPlaceText = "";
}
if (onesPlaceNumber == 1 && tensPlaceNumber != 1)
{
onesPlaceText = "one";
}
if (onesPlaceNumber == 2 && tensPlaceNumber != 1)
{
onesPlaceText = "two";
}
if (onesPlaceNumber == 3 && tensPlaceNumber != 1)
{
onesPlaceText = "three";
}
if (onesPlaceNumber == 4 && tensPlaceNumber != 1)
{
onesPlaceText = "four";
}
if (onesPlaceNumber == 5 && tensPlaceNumber != 1)
{
onesPlaceText = "five";
}
if (onesPlaceNumber == 6 && tensPlaceNumber != 1)
{
onesPlaceText = "six";
}
if (onesPlaceNumber == 7 && tensPlaceNumber != 1)
{
onesPlaceText = "seven";
}
if (onesPlaceNumber == 8 && tensPlaceNumber != 1)
{
onesPlaceText = "eight";
}
if (onesPlaceNumber == 9 && tensPlaceNumber != 1)
{
onesPlaceText = "nine";
}

return onesPlaceText;
}

string tensPlaceWrite(int tensPlaceNumber, int onesPlaceNumber)
{
string tensPlaceText;

if (tensPlaceNumber == 0)
{
tensPlaceText = "";
}

if (tensPlaceNumber == 1 && onesPlaceNumber == 0)
{
tensPlaceText = "ten";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 1)
{
tensPlaceText = "eleven";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 2)
{
tensPlaceText = "twelve";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 3)
{
tensPlaceText = "thirteen";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 4)
{
tensPlaceText = "fourteen";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 5)
{
tensPlaceText = "fifteen";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 6)
{
tensPlaceText = "sixteen";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 7)
{
tensPlaceText = "seventeen";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 8)
{
tensPlaceText = "eighteen";
}
if (tensPlaceNumber == 1 && onesPlaceNumber == 9)
{
tensPlaceText = "nineteen";
}

if (tensPlaceNumber == 2)
{
tensPlaceText = "twenty ";
}
if (tensPlaceNumber == 3)
{
tensPlaceText = "thirty ";
}
if (tensPlaceNumber == 4)
{
tensPlaceText = "forty ";
}
if (tensPlaceNumber == 5)
{
tensPlaceText = "fifty ";
}
if (tensPlaceNumber == 6)
{
tensPlaceText = "sixty ";
}
if (tensPlaceNumber == 7)
{
tensPlaceText = "seventy ";
}
if (tensPlaceNumber == 8)
{
tensPlaceText = "eighty ";
}
if (tensPlaceNumber == 9)
{
tensPlaceText = "ninety ";
}

return tensPlaceText;
}

string hundredsPlaceWrite(int hundredsPlaceNumber)
{
string hundredsPlaceText = "";

if (hundredsPlaceNumber == 0)
{
hundredsPlaceText = "";
}

if (hundredsPlaceNumber == 1)
{
hundredsPlaceText = "one hundred ";
}
if (hundredsPlaceNumber == 2)
{
hundredsPlaceText = "two hundred ";
}
if (hundredsPlaceNumber == 3)
{
hundredsPlaceText = "three hundred ";
}
if (hundredsPlaceNumber == 4)
{
hundredsPlaceText = "four hundred ";
}
if (hundredsPlaceNumber == 5)
{
hundredsPlaceText = "five hundred ";
}
if (hundredsPlaceNumber == 6)
{
hundredsPlaceText = "six hundred ";
}
if (hundredsPlaceNumber == 7)
{
hundredsPlaceText = "seven hundred ";
}
if (hundredsPlaceNumber == 8)
{
hundredsPlaceText = "eight hundred ";
}
if (hundredsPlaceNumber == 9)
{
hundredsPlaceText = "nine hundred ";
}

return hundredsPlaceText;
}






------------------------------------------

Check the last post for the problem.

Why is it like this? What am I doing wrong?

Any help would be appreciated.
__________________
My Trade Thread
Quote:
Originally Posted by Lakak View Post
Why do you need help? C++ is a passing grade
Quote:
Originally Posted by Marril View Post
Given that they've ramped up from colours to metals to gems, there's only one more option available to them.
Pokémon Plutonium and Uranium.

Last edited by legotack; 12/01/2009 at 05:44 PM.
legotack is offline   Reply With Quote
Old 12/01/2009, 01:34 PM   #2
Kayle
 
Kayle's Avatar
 
Images: 2
Send a message via MSN to Kayle Send a message via Skype™ to Kayle
The only issue I can see is this line:

for (int x = 0; x <= 9; x = x+ 1)
{
cout<<tensPlace(x);

If you only intend to count from 0 to 19, the tens place should only ever go to 1.
__________________
Team B-Side
|| cardmaker, competitive tcg player, competitive vg player. ||
|| programmer, game designer; fantasy writer, amateur artist. ||
.....the figter of shadows.....
Kayle is offline   Reply With Quote
Old 12/01/2009, 01:38 PM   #3
legotack
 
legotack's Avatar
 
Send a message via AIM to legotack
^Thanks for the help, but that didn't seem to work. I can't think what the problem is.
__________________
My Trade Thread
Quote:
Originally Posted by Lakak View Post
Why do you need help? C++ is a passing grade
Quote:
Originally Posted by Marril View Post
Given that they've ramped up from colours to metals to gems, there's only one more option available to them.
Pokémon Plutonium and Uranium.
legotack is offline   Reply With Quote
Old 12/01/2009, 01:50 PM   #4
Lakak
 
Lakak's Avatar
 
Send a message via AIM to Lakak
Why do you need help? C++ is a passing grade
Lakak is offline   Reply With Quote
Old 12/01/2009, 01:53 PM   #5
legotack
 
legotack's Avatar
 
Send a message via AIM to legotack
^Sig'd. Seriously, though, any help?
__________________
My Trade Thread
Quote:
Originally Posted by Lakak View Post
Why do you need help? C++ is a passing grade
Quote:
Originally Posted by Marril View Post
Given that they've ramped up from colours to metals to gems, there's only one more option available to them.
Pokémon Plutonium and Uranium.
legotack is offline   Reply With Quote
Old 12/01/2009, 02:07 PM   #6
bullados
 
bullados's Avatar
 
Images: 85
You've got three embeded for-loops. If I do my math right, you'll go through the inner loop 10*10*18=1800 times, significantly more than your "19" times. It seems like it's counting correctly (if 11 places off), just something's wrong with that loop. I think I've spotted it. Cut that +1 in your function calls. It's not necessary, and it's throwing your results off by 11 places.

So, try working with those for a little while (cut out that initial loop, or at least comment it out), and see what happens.
__________________
2008 North American Professor Cup Champion
Minnesota Plasma Storm Prereleases
Battle Road Spring 2013
If you know of any asynchronous multi-camera video recording software, please PM. Thank you!
bullados is offline   Reply With Quote
Old 12/01/2009, 02:47 PM   #7
legotack
 
legotack's Avatar
 
Send a message via AIM to legotack
^Thanks a ton bullados, it now almost works from 1-99. The only problem is that it does not show up when the ones place is 0 (10, 20, 30, etc.). The OP has been updated with my newest code. I can't seem to find the problem. Thanks in advance!
__________________
My Trade Thread
Quote:
Originally Posted by Lakak View Post
Why do you need help? C++ is a passing grade
Quote:
Originally Posted by Marril View Post
Given that they've ramped up from colours to metals to gems, there's only one more option available to them.
Pokémon Plutonium and Uranium.
legotack is offline   Reply With Quote
Old 12/01/2009, 02:55 PM   #8
bullados
 
bullados's Avatar
 
Images: 85
your second for loop goes from 1 to 9. Typo much? LOL!

Also, have you tried using a Switch-Case type statement? It's much easier to read than endless if-then statements...
__________________
2008 North American Professor Cup Champion
Minnesota Plasma Storm Prereleases
Battle Road Spring 2013
If you know of any asynchronous multi-camera video recording software, please PM. Thank you!
bullados is offline   Reply With Quote
Old 12/01/2009, 03:31 PM   #9
p i k a c h u
 
p i k a c h u's Avatar
 
in kayles first post it looks like a bunch of text faces like:)and:9 and;0 ect.lol
__________________
I swear to god when my Magikarp evolves he's going to kill you all!
PokeNews:)
p i k a c h u is offline   Reply With Quote
Old 12/01/2009, 05:44 PM   #10
legotack
 
legotack's Avatar
 
Send a message via AIM to legotack
Sorry to bother you again, I just have one more problem. I'm working on the hundreds, but there is a problem. My code is in the OP. My problem is that the number that is big, bold, and in red changes many things for some reason. If it is at 9, the program starts at 705 and goes up to 999. If it is at 1 it starts at 1 and goes to 199. If it is at 2 it starts at 5 and goes to 299. Why is this and how do I fix it?

Thanks again!
__________________
My Trade Thread
Quote:
Originally Posted by Lakak View Post
Why do you need help? C++ is a passing grade
Quote:
Originally Posted by Marril View Post
Given that they've ramped up from colours to metals to gems, there's only one more option available to them.
Pokémon Plutonium and Uranium.
legotack is offline   Reply With Quote
Old 12/01/2009, 06:20 PM   #11
bullados
 
bullados's Avatar
 
Images: 85
You're trying too hard. Just go from zero. The code can be modified from there.
__________________
2008 North American Professor Cup Champion
Minnesota Plasma Storm Prereleases
Battle Road Spring 2013
If you know of any asynchronous multi-camera video recording software, please PM. Thank you!
bullados is offline   Reply With Quote
Old 12/01/2009, 09:30 PM   #12
The Anaconda
 
The Anaconda's Avatar
 
Send a message via MSN to The Anaconda
just a comment on the style, lego, change all your "whatever = whatever + 1"'s to "whatever++", it looks nicer, and also has less chance of doing weird things to your loops

second, I would try making all your loops uniform. at the moment, you have hundreds place going from 0 to 9, tens place going from 0 to nine, but ones place going from 0 to 10, it probably would be a little easier to control if you do them all the same

but more of a problem is this loop
Code:
for (int tensPlaceNumber = 0; tensPlaceNumber <= 9; tensPlaceNumber = tensPlaceNumber)
which is never going to change value ever the way it's written

(another case for using i++ in loops for incrementing by ones, so you can easily tell when somethings wrong when glancing at it)
__________________
SLCPokemon - Part of Andrea's Army

Read the fanfic Skewed, the story of a twisted future for the world of Pokemon. (last updated 10-10-10)

Regular Spelling (personal blog, updated often, more stories there)
The Anaconda is offline   Reply With Quote
Old 12/02/2009, 03:42 AM   #13
legotack
 
legotack's Avatar
 
Send a message via AIM to legotack
Thanks for the help, now my code is much shorter and easier to follow. I started out doing what Anaconda suggested, but it didn't work, and after trying it again, it still didn't. Although I start everything at 0, like bullados suggested, my program still just starts at 704. Am I doing something wrong?

Back to back posts merged. The following information has been added:

After trying with many things, I have found the problem. For some reason Windows puts a limit on the execution window (I'm not sure what it's called) and so 705 is the highest it goes. Thanks again!
__________________
My Trade Thread
Quote:
Originally Posted by Lakak View Post
Why do you need help? C++ is a passing grade
Quote:
Originally Posted by Marril View Post
Given that they've ramped up from colours to metals to gems, there's only one more option available to them.
Pokémon Plutonium and Uranium.

Last edited by legotack; 12/02/2009 at 03:59 AM. Reason: Doublepost Eliminator
legotack is offline   Reply With Quote
Old 12/02/2009, 04:25 AM   #14
Chairman Kaga
 
Chairman Kaga's Avatar
 
Send a message via MSN to Chairman Kaga
This is more C than C++ (my C++ is quite rusty), but....

Code:
#include <iostream>
#include <string>

using namespace ***;

const char *onesText[10]  = {"","one","two","three","four","five","six","seven","eight","nine"};
const char *tysText[10]   = {"","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
const char *teensText[10] = {"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};

int main() {
    for (int hundreds = 0; hundreds <= 9; hundreds++) {
        for (int tens = 0; tens <= 9; tens++) {
            for (int ones = 0; ones <= 9; ones++) {
                if (hundreds == 0 && tens == 0 && ones == 0) continue; // Skip zero
                cout << (hundreds * 100 + tens * 10 + ones) << " is ";
                if (hundreds)
                    cout << onesText[hundreds] << " hundred ";
                if (tens > 1)
                    cout << tysText[tens] << " ";
                cout << ((tens == 1) ? teensText[ones] : onesText[ones]) << endl;
            }
        }
    }

    return 0;
}
You know this doesn't really go to a trillion, though
__________________
Stephen Clouse
Kansas City Pokémon
Chairman Kaga is offline   Reply With Quote
Old 12/03/2009, 05:00 PM   #15
Kayle
 
Kayle's Avatar
 
Images: 2
Send a message via MSN to Kayle Send a message via Skype™ to Kayle
Quote:
Originally Posted by Chairman Kaga View Post
This is more C than C++
Wow. That was... awesome.

I have a couple questions about it though -

"const char *onesText[10]"

Why is the asterisk there? How are you storing strings (words) in an array allocated for char? I suppose that might have to do with pointers and advanced-array-structure (as Bullados said), and I haven't studied pointers yet, but I'm, uh, a quick study. And ambitious. :3
__________________
Team B-Side
|| cardmaker, competitive tcg player, competitive vg player. ||
|| programmer, game designer; fantasy writer, amateur artist. ||
.....the figter of shadows.....
Kayle is offline   Reply With Quote
Old 12/03/2009, 08:04 PM   #16
Chairman Kaga
 
Chairman Kaga's Avatar
 
Send a message via MSN to Chairman Kaga
Quote:
Originally Posted by Kayle View Post
"const char *onesText[10]"

Why is the asterisk there? How are you storing strings (words) in an array allocated for char? I suppose that might have to do with pointers and advanced-array-structure (as Bullados said), and I haven't studied pointers yet, but I'm, uh, a quick study. And ambitious. :3
It can also be written as const char* onesText[10] (the space before the * is one of those old style habits that I can't seem to kill).

A string literal ("string") is a pointer to the specified string on the stack (which gets auto-allocated by the compiler).

char*[] defines an array of pointers to strings, which we then populate with our stack pointers.

Pretty basic pointer stuff.

Now try the Perl version
__________________
Stephen Clouse
Kansas City Pokémon
Chairman Kaga is offline   Reply With Quote
Old 12/04/2009, 02:00 PM   #17
Kayle
 
Kayle's Avatar
 
Images: 2
Send a message via MSN to Kayle Send a message via Skype™ to Kayle
Wheeee, Perl. That just looks... lovely.


But yeah. Is char*[] a special case or something that points to strings rather than characters? Like, if I did int*[], that would be an array of pointers to integers...?

I need to just read about pointers myself.
__________________
Team B-Side
|| cardmaker, competitive tcg player, competitive vg player. ||
|| programmer, game designer; fantasy writer, amateur artist. ||
.....the figter of shadows.....
Kayle is offline   Reply With Quote
Old 12/02/2009, 06:53 AM   #18
bullados
 
bullados's Avatar
 
Images: 85
That's BEAUTIFUL, Stephen! I don't think I could've come up with anything prettier than that. Though, I think it might be above the coding level of OP with the use of pointers and the very advanced array structure you've used for this.

Find a C++ manual and look up the Switch and Case statements. Those will make your life easier.
__________________
2008 North American Professor Cup Champion
Minnesota Plasma Storm Prereleases
Battle Road Spring 2013
If you know of any asynchronous multi-camera video recording software, please PM. Thank you!
bullados is offline   Reply With Quote
Old 12/03/2009, 01:50 AM   #19
Chairman Kaga
 
Chairman Kaga's Avatar
 
Send a message via MSN to Chairman Kaga
Quote:
Originally Posted by bullados View Post
That's BEAUTIFUL, Stephen!
Sorry, I'll fix that:

perl -e 'for(split//,"#defghilnorstuvwxy\40\n"){push@d,$_}@f=split//,"\0\f\2\10\0\0\t\10\2\0\2\7\2\16\26\30\f\17\t\24\ 17\36!\47\26\f\21\24\5\n\2\34\f\5\6\n\25\"46-\0\3\t\r\n=?72\27>7.\3\6*J\0038F\6N.\13\6\20\0T\20 OWU<\13\40\"^!\10Za,.\2\6\4\5\f\35ikEmj<\10\6\33\0 t\33Zx\2<\22\0\22\6\13~\22\5\r\10\0011\1~\23";$o=o rd(shift@f);$t=$d[$o];while($_=shift@f){$n=ord($_);if($n<@d){$s=$d[$n];$t.=$s;$c=substr$s,0,1;push@d,$d[$o].$c;$o=$n}else{$s=$d[$o].$c}}@t=split/#/,$t;for(1..~~@t*30-21){split//,reverse;print$_,$t[31],$_[2]&&$t[$_[2]*3].$t[32],$_[1]>1&&$t[$_[1]*3+2].$t[30],($_[1]==1?$t[$_[0]*3+1]:$t[$_[0]*3]),$t[33]}'

Okay, the board is dumb and likes to insert random spaces in the above code (which screws it up), but it leaves [CODE] blocks alone. So:

Code:
perl -e 'for(split//,"#defghilnorstuvwxy\40\n"){push@d,$_}@f=split//,"\0\f\2\10\0\0\t\10\2\0\2\7\2\16\26\30\f\17\t\24\17\36!\47\26\f\21\24\5\n\2\34\f\5\6\n\25\"46-\0\3\t\r\n=?72\27>7.\3\6*J\0038F\6N.\13\6\20\0T\20OWU<\13\40\"^!\10Za,.\2\6\4\5\f\35ikEmj<\10\6\33\0t\33Zx\2<\22\0\22\6\13~\22\5\r\10\0011\1~\23";$o=ord(shift@f);$t=$d[$o];while($_=shift@f){$n=ord($_);if($n<@d){$s=$d[$n];$t.=$s;$c=substr$s,0,1;push@d,$d[$o].$c;$o=$n}else{$s=$d[$o].$c}}@t=split/#/,$t;for(1..~~@t*30-21){split//,reverse;print$_,$t[31],$_[2]&&$t[$_[2]*3].$t[32],$_[1]>1&&$t[$_[1]*3+2].$t[30],($_[1]==1?$t[$_[0]*3+1]:$t[$_[0]*3]),$t[33]}'
__________________
Stephen Clouse
Kansas City Pokémon

Last edited by Chairman Kaga; 12/03/2009 at 05:54 AM.
Chairman Kaga is offline   Reply With Quote
Old 12/03/2009, 04:48 PM   #20
ExoByte
Master Trainer
 
ExoByte's Avatar
 
Images: 2
OOPMAN says:
Create a class that has 16 ints, one for each digit. (16 right?) (or, for more flexibility, create one that can grow as needed w/ infinite precision)
give it a function "increment" that does the right thing (carrying, etc)
give it a function "output" that does the right thing for each digit. (you could even pull some wonkiness and make 3 digit subclasses to display "one/ten/hundred" depending on it's significance)
Loop increment/output 1 trillion times.
__________________
-Have Fun!
Dylan "ExoByte" Mayo
TPCi, R&D
Quote:
Originally Posted by NoPoke
[the quick brown fox jumps over the 17 character dog]
ExoByte is offline   Reply With Quote
Old 12/02/2009, 09:01 PM   #21
homeofmew
 
homeofmew's Avatar
 
Images: 15
Send a message via MSN to homeofmew Send a message via Skype™ to homeofmew
i love how using name space standard is censored.
__________________
[ homeofmew |Christine "Tina" Michie]
[Masters Division | Houston, Texas/ USA
]
[Fly For Fun |Server: Tanuki| Guild: iCe | Level/ Class: 150 [H]ero Ranger/Crackshooter]
14,500 + Hours of Playtime

homeofmew is offline   Reply With Quote
Old 12/04/2009, 02:12 PM   #22
legotack
 
legotack's Avatar
 
Send a message via AIM to legotack
Thanks for all the help! Chairman Kaga, that is amazing. Too bad I can't use arrays. Exobyte, sorry, but I don't know what a class is and I'm having trouble finding out what it is. Is there any way you can explain it to me? Chairman Kaga, I've got one question. Out of pure curiosity, how do you run Perl scripts on a mac? I hope I can one day learn Perl. I am working on the thousands right now, and I am having some success.

Thanks again!
__________________
My Trade Thread
Quote:
Originally Posted by Lakak View Post
Why do you need help? C++ is a passing grade
Quote:
Originally Posted by Marril View Post
Given that they've ramped up from colours to metals to gems, there's only one more option available to them.
Pokémon Plutonium and Uranium.
legotack is offline   Reply With Quote
Old 12/04/2009, 02:29 PM   #23
Kayle
 
Kayle's Avatar
 
Images: 2
Send a message via MSN to Kayle Send a message via Skype™ to Kayle
Quote:
Originally Posted by legotack View Post
Thanks for all the help! Chairman Kaga, that is amazing. Too bad I can't use arrays. Exobyte, sorry, but I don't know what a class is and I'm having trouble finding out what it is. Is there any way you can explain it to me? Chairman Kaga, I've got one question. Out of pure curiosity, how do you run Perl scripts on a mac? I hope I can one day learn Perl. I am working on the thousands right now, and I am having some success.

Thanks again!
Classes are amazing custom variable types you define that hold several variables of many types.

Code:
class example
{
public:
int number;
string name;
int age;
};
In this case, you could then:

Code:
void main()
{
example object1;
}
You would create a variable, named object1, of type "example", which you defined in the class tag. Classes go above the main and above function prototypes most of the time, I think.

The object1 variable has three internal variables, similar to an array, but those variables are different types. You would refer to them using the dot operator - so if I wanted to set the "number" variable in object1, I'd use "object1.number = 9" or something like that. The same goes for calling them, etc.

There's a lot more to it [constructors that will initialize your values, functions that relate to the specific instance of the class, public and private, etc;] but that's a good basic definition... I hope.
__________________
Team B-Side
|| cardmaker, competitive tcg player, competitive vg player. ||
|| programmer, game designer; fantasy writer, amateur artist. ||
.....the figter of shadows.....
Kayle is offline   Reply With Quote
Old 12/04/2009, 02:58 PM   #24
ExoByte
Master Trainer
 
ExoByte's Avatar
 
Images: 2
Quote:
Originally Posted by legotack View Post
Thanks for all the help! Chairman Kaga, that is amazing. Too bad I can't use arrays. Exobyte, sorry, but I don't know what a class is and I'm having trouble finding out what it is. Is there any way you can explain it to me? Chairman Kaga, I've got one question. Out of pure curiosity, how do you run Perl scripts on a mac? I hope I can one day learn Perl. I am working on the thousands right now, and I am having some success.

Thanks again!
It might be ahead of your time...let me see if i can do this off the top of my head (apologize for any typo/syntax jazz). Also this might have a unit or two of psuedocode in it. Also also, this thinks that "twoty four" is a number, so deal with your own string massaging, etc.
#include/using relevant stuff.
Code:
Class BigInt
{

private:

	int Trillionizer[13]; 

public:
	
	BigInt()
	{
		int xx;

		for (xx=0;xx>12;Trillionizer[xx++]=0)
	}

	void Increment()
	{
		int xx;

		Trillionizer[0]++

		for (xx=0;xx>12;xx++)
		{
			if (Trillionizer[xx] = 10)
			{
				Trillionizer[xx] = 0;
				Trillionizer[xx+1]++;
			}
		}
	}

	void Output()
	{

		bool GroupFlag;		
		int Group
		String stringamajig = "";
		String Groups[4] = {"Billion","Million","Thousand",""};
		String digits[10] = {"Nine","Eight", (Etc...}


		If (Trillionizer[12] = 1)
			Stringmajig = "1 Trillion.  Shipoopi!";

		else
		
			for (group = 3; group<0; group--)
			{
				GroupFlag = FALSE;

				for (THO = 2, THO<0; THO--)
				{
					if (Trillionizer[3*group+2])
						Stringamajig += digits[Trillionizer[3*group+2]]	+ " hundred "
						GroupFlag = TRUE;
					if (Trillionizer[3*group+1])
						Stringamajig += digits[Trillionizer[3*group+2]]	+ " ty "	
						GroupFlag = TRUE;
					if (Trillionizer[3*group+0])
						Stringamajig += digits[Trillionizer[3*group+2]]	+ " "		
						GroupFlag = TRUE;
				}

				If (Groupflag)
					Stringmajig += Groups[group] + " ";
			}
		
		cout << stringmajig;
		
		return
	}
		
}



int main (void)
{
	int x = 0;	
	BigInt TrillionLvX;
	
	for (x;x>1000000000000;x++)
	{
		TrillionLvX.increment;
		TrillionLVX.output;
	}
	

	return 0;
}

...although if you can't use arrays you probably REALLY can't use classes :P
__________________
-Have Fun!
Dylan "ExoByte" Mayo
TPCi, R&D
Quote:
Originally Posted by NoPoke
[the quick brown fox jumps over the 17 character dog]
ExoByte is offline   Reply With Quote
Old 12/04/2009, 04:45 PM   #25
bullados
 
bullados's Avatar
 
Images: 85
That looks more Java than C++, XO. I don't think that C++ has that concept of "public" and "private" (though it's been a while since I actually *coded* in C++)
__________________
2008 North American Professor Cup Champion
Minnesota Plasma Storm Prereleases
Battle Road Spring 2013
If you know of any asynchronous multi-camera video recording software, please PM. Thank you!
bullados is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:03 PM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

This site is owned and operated by Team Compendium, Inc.
All content is © 2000-2011 Team Compendium, Inc.
The PokeGym is not affiliated with The Pokémon Company, International
or any anime or video game companies.