Sunday, July 12, 2009

C++ fractal program?

This is supposed to be a C++ program that is for (8,0). It prints out the fractal using *'s. Why isn't it working? This is what I have so far:





#include %26lt;iostream%26gt;


#include %26lt;cmath%26gt;


using namespace::std;





using std::cout;





void pattern(int nstars, int startcol);





int main()


{





const int nstars = 8;


int startcol = 0;


pattern (nstars - 32, startcol);


for (int i = 0; i %26lt;= startcol; i ++)


{


cout %26lt;%26lt; " ";


}


for (int j = 0; j %26lt;= nstars; j++)


{


cout %26lt;%26lt; "* ";


}


cout %26lt;%26lt; endl;





}





void pattern (int nstars, int startcol)


{


if(nstars != 0);


}








Please Help!

C++ fractal program?
Look at the code for your pattern function. It doesn't do anything.





You've got for loops elsewhere that look like they should be inside of the pattern function. Why not try moving them, and see if you have better luck.





I suspect you've written too much code at once. Why not start over, and build the code up one step at a time. For example, can you write a version of pattern() that just prints n stars, where n is a function parameter? Once you've done this, it should be easy to expand the code to solve the complete problem.

surveys

No comments:

Post a Comment