Thread: Please more help!

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    12

    Please more help!

    I am dieing over this project. and whatever i put in doesnt seem to work please help!

    //r = rows,s = stars, spl = stars per line

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int r,s,spl,x,space,spacepl;
        spl = 7;
        spacepl = 7;
        
        for(r = 1;r <= 7;r++)
        {
              for(space = 1;space < spacepl;space++)
              {
                    cout<<" ";
              }
              for(s = spl;s <= 7;s++)
              {
                    for(x = spl;x <= 7;x++)
                    {
                          cout<<"*";
                    }
              }
              spl--;
              spacepl--;
              cout<<endl;
        }
        cin.ignore(2);
        return 0;
    }
    and the output for this is:
    Code:
          *
         ****
        *********
       ****************
      *************************
     ************************************
    *************************************************
    please help me.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    If I understand this correctly, you need
    Code:
    row 1 : 6 spaces 1 star
    row 2 : 5 spaces 2 stars
    row 3 : 4 spaces 3 stars
    row 4 : 3 spaces 4 stars
    row 5 : 2 spaces 5 stars
    row 6 : 1 space  6 stars
    row 7 : 0 spaces 7 stars
    [edit]Nope, that ain't right.
    Code:
    row 1 : 6 spaces 1 star
    row 2 : 5 spaces 3 stars
    row 3 : 4 spaces 5 stars
    row 4 : 3 spaces 7 stars
    row 5 : 2 spaces 9 stars
    row 6 : 1 space  11 stars
    row 7 : 0 spaces 13 stars
    So if r goes from 1 to 7, then spaces goes from 6 to 0, and stars go from 1 to 2*r - 1.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    12
    wow thx so much it just clicked, your awsome!

Popular pages Recent additions subscribe to a feed