| | |
unknown error at run time urgent help needed
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2006
Posts: 3
Reputation:
Solved Threads: 0
this program compiles and gives the following return state/code
Exit code: -1073741819
this is very irritating i would also ask please do not post the output file here this is a challenge from arcanum i just want a working program.
please help me with this program.
this is what i have to do
thanks to all who help me as well
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.
Exit code: -1073741819
this is very irritating i would also ask please do not post the output file here this is a challenge from arcanum i just want a working program.
please help me with this program.
this is what i have to do
thanks to all who help me as well
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.
Last edited by backstabber; Dec 14th, 2006 at 11:51 pm. Reason: forgot to tell you what i was trying to do
Your coding style is really quite terrible. There is nothing wrong with putting stuff on separate lines to make it easier to read. Easy reading is much better than being cute. For example:
would be much better something like this. The coding style below makes it immediately clear where the beginning and ending of the blocks are located -- it is not necessary for the programmer to hunt all over the file for the matching braces.
Putting two braces on the same line like you did just looks very sloppy coding.
I this this is a correction
C++ Syntax (Toggle Plain Text)
for(int r = 1; r <= rows; r++) { <snip> for(b = 1; b <= rows; b++){ if(best < maxsum[rows][b]) best = maxsum[rows][b]; cout << "it works here: fourth for loop: iter:"<<b<<" "; }}
would be much better something like this. The coding style below makes it immediately clear where the beginning and ending of the blocks are located -- it is not necessary for the programmer to hunt all over the file for the matching braces.
Putting two braces on the same line like you did just looks very sloppy coding.
C++ Syntax (Toggle Plain Text)
for(int r = 1; r <= rows; r++) { for(b = 1; b <= rows; b++) { if(best < maxsum[rows][b]) best = maxsum[rows][b]; cout << "it works here: fourth for loop: iter:"<<b<<" "; } }
I this this is a correction
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> using namespace std; int main() { int num, rows; unsigned int maxsum[200][200] = {0}; int best = 0; //cout << "it works here: definitions "; ifstream infile("INPUT.TXT"); ofstream outfile("OUTPUT.TXT"); //cout << "it works here: filestreams "; infile >> rows; //cout << "it works here: infilestream rows "; for(int b = 0; b < 200; b++) { //maxsum[0][b] = 0; //cout << "it works here: first for loop: iter:" << b<<" \n"; for(int r = 1; r < rows; r++) { //cout << "it works here: second for loop: iter:"<<r<<" "; //maxsum[r][0] = 0; for(int c = 1; c < r; c++) { //cout << "it works here: third for loop: iter:"<<c<<" "; infile >> num; // cout << num << " "; maxsum[r][c] = (maxsum[r-1][c-1] > maxsum[r-1][c]) ? (maxsum[r-1][c-1] + num) : (maxsum[r-1][c] + num); // cout << maxsum[r][c] << " " << maxsum[r-1][c-1] << " " << maxsum[r-1][c] << " "; } maxsum[r][r+1] = 0; } for(int k = 1; k < rows; k++) { if(best < maxsum[rows][k]) best = maxsum[rows][k]; //cout << "it works here: fourth for loop: iter:"<<b<<" "; } } outfile << best; cout << "it works here: last thing\n"; return 0; }
Last edited by Ancient Dragon; Dec 15th, 2006 at 1:06 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Dec 2006
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
ust out of curiosity what are the restrictions set on solving the puzzle. That is, could you use a tree or stacks or someother structure besides arrays or are you restricted to use of just arrays?
![]() |
Similar Threads
- Run-time error '5' (Windows NT / 2000 / XP)
- Run-time Error when printing Array Contents. (C)
- "Run time error, do you wish to debug?" (Web Browsers)
- Run-Time Error..? (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Sorting from file
- Next Thread: Adding binary values from a file
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






