I can't get this to work right. I have been workiing on it for a long time now but to no avail. It is a 3 section nested loop (if there is such a thing). It is supposed to print out a graph for each score but when it runs it just prints out
*
*
*
*
*
and I don't know what it prints out before that because it moves so fast and then it ends.
Am I doing something wrong?
I did haveCode:cout << "SCORE" << setw(13) << "FREQUENCY" << setw(13)<< "GRAPH"<< endl; // Score output loop for (int score=1; score < 10001; score++){ for (;(frequency[score]>1) && (frequency[score]< 10001);) cout<< setw(5) << score << setw(5) << frequency[score] << setw(5); // Print bar for (int i=1; i <= frequency[i]; i++) cout <<"*"; cout << endl; }
if (!(frequency[i]==0)) cout << "*";
cout << endl;
after
cout<< setw(5) << score << setw(5) << frequency[score] << setw(5);
instead of the 2nd for loop.
But the problem was that if reads any other statements as else. But I wanted it to go back up to for to increment the number again.
One of my biggest goals is to stop it from printing 0's.




Reply With Quote