![]() |
help with assignment code returns no answer
1 Attachment(s)
i have been on this particular challenge for quite a while now and i want to finish it but i do not know what is wrong with my source.
i would appreciate help and thanks in advance. this program is trying to do the following Number Triangles 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 The above figure shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right. In the sample shown above, the route from 7 to 3 to 8 to 7 to 5 produces the highest sum: 30. my triangle is in the zip file. :
#include <iostream>the input file is included |
>i would appreciate help
I'm sure you would, but until you ask an actual question, you won't get actual help. >and thanks in advance. "Thanks in advance" is used by bill collectors as a way to create a feeling of dominance with the expectation of compliance. Some people are very offended by it, so I would recommend saving your thanks until after you've been helped (but never forget it). I also find your name to be humorously ironic after watching your thread on Daniweb. |
i would have thought the name of the thread was enough.
and as to my name i did not stab daniweb in the back by moving into programmingforums because they are friends or allies or something this thread is to help me complete the assignment the daniweb one was to get rid of the "unknown error". |
>i would have thought the name of the thread was enough.
It's not. 'No answer' and 'incorrect answer' are two very different things. From what I've seen of your other thread(s), the problem is that the result is a very large negative number, which suggests that you're overflowing the data type. |
I think this will work :
:
|
>I think this will work
If by "work" you mean stack overflow then yes, it works perfectly. ;) Tell me, what are the values of i and j after these recursive calls? :
solve(i++ ,j , sum_temp); |
sorry to every body here is the revised code :
:
#include <iostream>I will work today to solve it iteratively. |
Quote:
"I THINK THIS WILL WORK", it doesn`t mean that i was 100% sure of it working correctly but as you can see now i think that the new post will work. I only tested it with those two tables, if you see a bug please tell me. ;) |
>If you read carefully to what i said
I did read carefully what you said. That's how I knew it was wrong, and a cursory glance at the code was solid proof. ;) You don't guess when it comes to correctness, you test and verify. And of course, you only post untested code in places like this (where people like me reside) if you're supremely confident that it's perfect. ;) |
Quote:
:
#include <iostream>Again i tell that if ANYONE sees a bug please report it here. |
| All times are GMT -5. The time now is 1:38 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC