I'm having trouble getting this to work with only 2 cout statements. I have 4 at the moment. This is my first class in programming. Any help would be appreciated, to shine some light on my frustrated head.
Code:#include "stdafx.h" #include <iostream> #include <string> using namespace std; int const MAXSTARS = 9; int i , j ; class Diamond { private: public: Diamond(){ // top half of diamond for(i = 0 ; i < (MAXSTARS/2 + 1) ; i++) { for(j = i ; j < (MAXSTARS/2) ; j++) // used to align, putting in spaces cout << " " ; for(j = 1 ; j <= (i*2 + 1) ; j++) // puts in the actual astericks cout << "*" ; cout << endl ; } // bottom half of diamond for(i = (MAXSTARS/2) ; i > 0 ; i--) { for(j = (MAXSTARS/2 + 1) ; j > i ; j--) // used to align, putting in spaces cout << " " ; for(j = (i*2 - 1) ; j > 0 ; j--) // puts in the actual astericks cout << "*" ; cout << endl ; } } }; int _tmain(int argc, _TCHAR* argv[]) { Diamond DM; return 0; }



LinkBack URL
About LinkBacks


