| garmot17 (3) | |||
| |||
|
|
|||
| PopCOrn (4) | |
|
Hello, I am really new to C++ and i stumbled across this tread. and thought hey i could learn something here =) the first couple project were pretty simple and easy but, the pancake one is giving me alot of trouble... Currently im able to sort the number, but i can''t say who ate the most.. so please help me out :) http://codepad.org/typHzJdB | |
|
Last edited on
|
|
| Shadow Addict (195) | |
| I'm really enjoying the graduation program. It's actually the biggest C++ project I've tackled so far, and it's giving me a bit of insight into organizing a program. I just finished implementing the linked list, and I'm about to move onto the display elements of the program. I'll post some results when I'm done. | |
|
|
|
| computerquip (1892) | |
| PopCOrn, I'm just going to tell you that you can make your program about 1/3 a size it is now and about 100 times less complex. For now, I'm not going to give a direct answer since you need to figure it out as a brain teaser :P | |
|
|
|
| PopCOrn (4) | |
|
Computerquip, i really tried to figure it out before i posted =-\ but i really dont know how to. im currently studying alot again before i put my new knowlegde into work. also i believe it must be something with for, do while loops. ( i assume ). i hope u could help me out here =) ( i will test ur code and then study off it again. so therefor even if u tell me the solution i still learn from it.. | |
|
|
|
| Shadow Addict (195) | |
| computerquip: I don't want to look at your code for the graduation problem lest I spoil some of it for myself, but how long is all of your code? I'm not done, but so far I feel like mine is too short, and I'd like to know how long a more experienced programmer's code ended up. | |
|
|
|
| chrisname (5896) | |
| Well, how many lines is it? IIRC computerquip's was less than 400 LOC. I was going to do the graduation program but never did. Maybe I'll try it some time. | |
|
|
|
| xander333 (622) | |||
|
I'm trying the Pancakes one, and I'm stuck already :( I don't know how to find the highest number...suggestions?
| |||
|
|
|||
| PopCOrn (4) | |||
|
Hello there again, i did the fun with functions project so please give me feedback on how i can improve my coding. =) try to not let me get used to bad habbits. Probally to long for a simple program but it does the job =)
| |||
|
|
|||
| computerquip (1892) | ||
|
Mine was incomplete though and had some rather messy code involved. I quit around 3/4 of the way cuz of boredom. I'll probably start from scratch here soon since I don't even like the design I went with... @ popcorn, the purpose of these challenges are to... er... challenge you. If you can't figure it out, Sleep on it and please do! I'll give you a decent hint to give you a boost.
Also, don't use system("pause"). That doesn't work on my laptop since I'm running Linux. Use getchar() or something. | ||
|
|
||
| chrisname (5896) | |
|
@computerquip, We've been over this -- it's std::cin.get()! getchar() is a C function ;) | |
|
|
|
| Albatross (3551) | |
|
That's no reason to not use it, is it? It does the same thing and possibly requires fewer characters (depending on whether or not you use namespace std, although getchar() could require you to #include <cstdio>). -Albatross | |
|
Last edited on
|
|
| chrisname (5896) | |
| No, it doesn't make any difference AFAIK. But It's still technically incorrect. Consistency is good. | |
|
|
|
| helios (10126) | ||
| ||
|
|
||
| PopCOrn (4) | |
| Computererquip, well all my thing do the thing they ask for, and trust me i tried to figure it out myself but after this tip ill probally be able to fix the pancake one =) | |
|
|
|
| computerquip (1892) | |
|
SPOILER: http://codepad.org/60iarWV9 EDIT: Here's my version of it: http://codepad.org/miuCRAO8 Use a C style of bookmarking in the array to grab values you want... This function reduces your code while still getting the greatest player. | |
|
Last edited on
|
|
| xander333 (622) | |
|
And how do you get it to say it all in order? like: P1 ate 10 P2 ate 8 ... P10 ate 0 ? Is it hard? | |
|
|
|
| computerquip (1892) | |
|
Oh, didn't even see that. Not at all. In this case, a simple sort algorithm of the array would suffice. I'll show a homemade example later, I need to move some stuff to my new home. | |
|
|
|
| xander333 (622) | |
|
Ok thanks computerquip :) I didn't get there yet in C++ for dummies ... | |
|
|
|
| Albatross (3551) | |
|
http://en.wikipedia.org/wiki/Bubble_sort Shortened explanation of what the algorithm does: Given an array A, the program runs through A, comparing two elements at a time. If the two elements that the program compares at a time are in the wrong order, they are swapped, and the iterator advances by one. If they are in the right order, the iterator advances by one anyway. When the iterator reaches the end of A, the iterator is set back to the beginning of A and runs again. The program completes when no swaps are made in one of the passes (meaning the array is sorted). It's slow, but it's easy to implement. -Albatross | |
|
|
|