Thread: Help Needed !!

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    6

    Help Needed !!

    i'm trying to draw this:

    & & & & & & &
    & * * * * * &
    & * * * * * &
    & * * * * * &
    & & & & & & &

    i know it's a combination of for loops.....but can anyone guide me in the right direction...the rest of my code is fine...i just need to know how to come up with this...thank you

  2. #2
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90
    ehh....
    Code:
    cout<<"& & & & & & & \n";
    cout<<"& * * * * * & \n";
    cout<<"& * * * * * & \n";
    cout<<"& * * * * * & \n";
    cout<<"& & & & & & &";
    Like that?

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    16
    You will need two for loops to do it. Just draw the filler char everytime except when your loop counter varibles == 0 or the max row/col number.

    There may be a better way to do this, but this code gets the job done.

    Code:
    #include <iostream>
    using namespace std;
    
    int main() {
    	char border = '&';
    	char filler = '*';
    
    	const int ROWS = 5;
    	const int COLS = 7;
    
    	for (int i = 0; i < ROWS; i++) { 
    		if (i == 0 || i == (ROWS - 1)) {
    			for (int j = 0; j < COLS; j++) {
    					cout << border;
    			}
    		} else {
    			for (int j = 0; j < COLS; j++) {
    				if(j == 0 || j == (COLS - 1)) 
    					cout << border;
    				else
    					cout << filler;
    			}
    		}
    		cout << "\n";
    	}
    }

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    You will need two for loops to do it. Just draw the filler char everytime except when your loop counter varibles == 0 or the max row/col number.



    hey thanks ....this is more along the lines of what i was trying to do.....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. Help Please
    By Moose112 in forum C++ Programming
    Replies: 9
    Last Post: 12-10-2006, 07:16 PM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  5. semi-colon - where is it needed
    By kes103 in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2003, 05:24 PM