Computer Science Canada trying to make BlackJack |
Author: | Viper [ Wed Nov 09, 2005 9:31 am ] | ||
Post subject: | trying to make BlackJack | ||
i have no idea what so ever on what is wrong heres my code(keep in mind im still new to C++ DevC++<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
Author: | Flikerator [ Wed Nov 09, 2005 9:37 am ] |
Post subject: | |
Put it in code tags, makes it easier to read Why is the deck 51 and not 52? EDIT - Oh yah, arrays are dif in C++ then Turing. They start at 0 EDIT- put this at the end of your program to see the output, instead of having a delay. It asks the user for input, and stores it no where. std::cin.get(); |
Author: | Viper [ Wed Nov 09, 2005 9:39 am ] |
Post subject: | |
the deck has 52 it just starts at 0 |
Author: | Tony [ Wed Nov 09, 2005 9:41 am ] |
Post subject: | |
but Quote: for(i=0;i<52;++i) so aren't you starting your counter at 1? |
Author: | wtd [ Wed Nov 09, 2005 1:34 pm ] | ||||
Post subject: | |||||
You declare:
And you get an array with 52 slots... that just happens to start at 0 and end at 51.
Gets you an array with only space for 51 cards. |
Author: | wtd [ Wed Nov 09, 2005 1:54 pm ] | ||
Post subject: | |||
Also, for the love of Bjarne Stroutrop... use some decent variable names!
|
Author: | Geminias [ Wed Nov 09, 2005 2:23 pm ] |
Post subject: | |
who writes all these codes you post wtd? you? lol |
Author: | wtd [ Wed Nov 09, 2005 2:48 pm ] |
Post subject: | |
Yes, I wrote that code. |
Author: | Flikerator [ Thu Nov 10, 2005 7:26 pm ] |
Post subject: | |
wtd wrote: Yes, I wrote that code.
Pwned! When did you get so good at Coding anyway wtd? |
Author: | wtd [ Thu Nov 10, 2005 7:28 pm ] |
Post subject: | |
Flikerator wrote: wtd wrote: Yes, I wrote that code.
Pwned! When did you get so good at Coding anyway wtd? I'm good? Nawww... decent, but not good. There are many many people who are way beyond me. And I've taught myself how to code, by watching people who are better than me, seeing what they're doing differently, and then trying to understand why they're doing things differently. |
Author: | [Gandalf] [ Thu Nov 10, 2005 9:00 pm ] |
Post subject: | |
Phaw, "CompSci God". Guess who "people who are better than me" are? You . |
Author: | wtd [ Thu Nov 10, 2005 9:04 pm ] |
Post subject: | |
[Gandalf] wrote: Phaw, "CompSci God".
Nawww... that just means I like to post. |
Author: | md [ Thu Nov 10, 2005 9:31 pm ] |
Post subject: | |
back on the original topic... kinda... did anyone else notice the horrible formating in the original code?! Seems to me that the first thing people should be taught is how to write readable code. |
Author: | wtd [ Thu Nov 10, 2005 9:56 pm ] |
Post subject: | |
Indeed. Indentation is your friend. Don't use tab, though, since it doesn't render consistently across different computers. |
Author: | Flikerator [ Fri Nov 11, 2005 5:02 pm ] |
Post subject: | |
Cornflake wrote: back on the original topic... kinda... did anyone else notice the horrible formating in the original code?! Seems to me that the first thing people should be taught is how to write readable code.
Im just getting used to indenting myself. Since turing had a built in indentation [F2] I rarely did it myself. Are there any text editors with a C/C++/C# Indentation in them, that you know of? |
Author: | wtd [ Fri Nov 11, 2005 5:14 pm ] |
Post subject: | |
Flikerator wrote: Cornflake wrote: back on the original topic... kinda... did anyone else notice the horrible formating in the original code?! Seems to me that the first thing people should be taught is how to write readable code.
Im just getting used to indenting myself. Since turing had a built in indentation [F2] I rarely did it myself. Are there any text editors with a C/C++/C# Indentation in them, that you know of? Almost certainly, but get used to doing it yourself. |
Author: | [Gandalf] [ Fri Nov 11, 2005 7:31 pm ] |
Post subject: | |
Please do. For me, one of the most important things about coding is indenting well. On your own. If you wish to not follow my advice, I don't see how you could have a hard time looking, I haven't seen an editor that doesn't have auto-indent. |
Author: | md [ Fri Nov 11, 2005 9:51 pm ] |
Post subject: | |
The only auto-indentation I use is the ones where each new line has the same number of blank spaces before the first character as the line before. It's really handy as even though I keep track of my own indentation putting 8 or 12 spaces at the front of each line slows typing quite a bit... |
Author: | wtd [ Fri Nov 11, 2005 10:06 pm ] |
Post subject: | |
Cornflake wrote: The only auto-indentation I use is the ones where each new line has the same number of blank spaces before the first character as the line before. It's really handy as even though I keep track of my own indentation putting 8 or 12 spaces at the front of each line slows typing quite a bit...
So only use 3 or 4 spaces as your unit of indentation. |
Author: | [Gandalf] [ Fri Nov 11, 2005 10:29 pm ] |
Post subject: | |
If only they made a convention, using tab would be a lot easier . |
Author: | md [ Fri Nov 11, 2005 10:57 pm ] |
Post subject: | |
wtd wrote: Cornflake wrote: The only auto-indentation I use is the ones where each new line has the same number of blank spaces before the first character as the line before. It's really handy as even though I keep track of my own indentation putting 8 or 12 spaces at the front of each line slows typing quite a bit...
So only use 3 or 4 spaces as your unit of indentation. 4 is my unit, however there are times when I get to 3 levels of indentation, and occasionally even 4. 3*4 is 12 Also many editors can be set up to replace tabs with a set number of spaces... and if they can't it's not hard to write a short program to change it all over for you... |
Author: | wtd [ Fri Nov 11, 2005 11:26 pm ] |
Post subject: | |
Cornflake wrote: wtd wrote: Cornflake wrote: The only auto-indentation I use is the ones where each new line has the same number of blank spaces before the first character as the line before. It's really handy as even though I keep track of my own indentation putting 8 or 12 spaces at the front of each line slows typing quite a bit...
So only use 3 or 4 spaces as your unit of indentation. 4 is my unit Excellent. I was worried you meant you used 8 or even twelve spaces for one unit of indentation. I've encountered this before. Try viewing that code in an 80x25 console. |