| Bazzy (6281) | ||||||
| ||||||
|
|
||||||
| computerquip (1892) | |
|
The problem with that, is that if they enter 1234123 it will be accounted for and not stopped. And even then, it will be counted as a B. Any other way you can think of? EDIT: I could make a check at the beginning I s'pose... | |
|
Last edited on
|
|
| firedraco (5414) | |||
Check if it is in the range first, then check everything else, perhaps?
| |||
|
|
|||
| computerquip (1892) | |||
Anything else? | |||
|
Last edited on
|
|||
| Bazzy (6281) | |||
This is just style but I suggest you having a more readable line style:
| |||
|
|
|||
| firedraco (5414) | |
| I don't know if this would affect the size, but you could remove the int argc/char** argv since you aren't using them. | |
|
|
|
| chrisname (5896) | |
| One thing; why use getchar() instead of std::cin.get()? getchar() is C... | |
|
|
|
| computerquip (1892) | |
|
@ Bazzy, I could but I changed it to show that that can be done that way. For one line cout lines, I see no problem with that plus it shortens the amount of lines produces by half and gives a clearn outlook. That's my opinion and sorry but I'm sticking by it. :D If they ever produce a .zip containing the test answers, I'll change it if requested too. @ firedraco, it shouldn't matter at all. I'll read up on the specification later about it. Until then though, I'll take them out since it's useless code that will never be used in this example. @ chrisname, I didn't think it mattered... Does it? Actually, I read up on "How to keep your console open". I find that using the limits header unnecessary and I can't help but not find an explanation for it. If anyone would really like to explain this to me, I'm all ears. | |
|
Last edited on
|
|
| chrisname (5896) | |
|
Not really; but getchar() is C and std::cin.get() is C++; I was just being picky. The std::numeric_limits<std::streamsize>::max thing, you mean? I can't remember, I gave a really good (I hope) explanation once... I'll try to find it. | |
|
|
|
| computerquip (1892) | |
| That's the one. I wouldn't mind an explanation but I fail to find one myself. | |
|
|
|
| computerquip (1892) | |||
Criticize it and I'll edit it. This was done pretty fast so I might have made a dumb error or two. | |||
|
Last edited on
|
|||
| chrisname (5896) | ||||||||||||||
You could make it more machine like:std::cout << "1. Water $1.50";and if you were really awesome you'd spend two hours working out how to make the text scroll with ncurses or something. That'd be awesome. By the way, why put std::endl at the end of every cout statement? Why not put a '\n' then an std::flush before you exit (to make sure stdout is printed)? It won't make a noticeable difference, particularly not in a program like this, but on something bigger it will slow it down. std::endl is basically
or std::cout << "\n" << std::flush;.inb4 computerquip;
Alternatively for the while loop:
| ||||||||||||||
|
Last edited on
|
||||||||||||||
| Aazor (14) | |
| I can't wait to start on the graduation program. Looks to be very interesting.. | |
|
|
|
| firedraco (5414) | |
|
Random Post: Meezu? Did you try to convert the romaji into American-like pronunciation? Because when I see that I pronounce it Meehzu >_> I would just use the original romaji. | |
|
|
|
| skater (15) | |||
hi everyone, my first post here :) .. my question is why is it when i started sorting the "number of pankes ate" the max stopped showing on execution ? been sitting here for an 1h now and cant figure it out , tnx for your time. (if i set the sorting part as a comment the max works fine) PS: any ideea on how i can keep the number of the person so i can print it at the end ? i was thining of making another array (pers[20][20]) to keep the number aswell, but that sounds like alot of work :D any easier way ? | |||
|
|
|||
| QWERTYman (458) | |
|
Uherhm...wrong forum http://www.cplusplus.com/forum/beginner/ | |
|
|
|
| skater (15) | |
| ok tnx, i will move it there then... the program was on the list , thought it was appropriate to post it here :) | |
|
|
|
| oopcdevcom (1) | |
| @computerquip: Any idea on when you will be making the source files available? | |
|
|
|
| computerquip (1892) | |
| Whenever I get around to it. I'm hesitating since I'm afraid people will look at it and not learn from it. | |
|
|
|
| Bazzy (6281) | |
| Maybe we could have that people, after trying the exercises themselves, to post their code and more expert programmers pointing out where that code can be improved. | |
|
|
|