looping problems...

Discussion in 'C++' started by tanmay, Jul 9, 2007.

  1. tanmay

    tanmay Guest

    please tell me how to get the following output using loops...

    1) *
    * *
    * * *
    * * * *
    * * *
    * *
    *



    2) abcdefgfedcba
    abcdefedcba
    abcdedcba
    abcdcba
    abcba
    aba
    a


    thankyou very much for solving my problem...
     
    tanmay, Jul 9, 2007
    #1
    1. Advertisements

  2. tanmay

    int2str Guest

    [ascii art snipped]

    You can find the complete answer to your question right here:
    http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2
    No problem! Our pleasure!
     
    int2str, Jul 9, 2007
    #2
    1. Advertisements

  3. tanmay

    RGambord Guest

    I'll point u in the right direction because I'm a nice guy. For
    problem 2 you are going to want a string 'abcdef' and 'edcba'. Modify
    those strings each loop and output them together. You will need to
    modify one, then the other for the loop. Tell your professor I send my
    regards for having such hardworking students.
     
    RGambord, Jul 9, 2007
    #3
  4. tanmay

    RGambord Guest

    Problem 1 is so easy I don't even need to help, but I will. start with
    string '*' add ' *' to it. Find a way to delete ' *' for the second
    half.
     
    RGambord, Jul 9, 2007
    #4
  5. tanmay

    BobR Guest

    Here ya go:

    // put your includes here: <iostream>, <string>, <vector>
    int main(){
    using std::cout; // for NG post
    std::string one( "1) *\n"
    " * *\n"
    " * * *\n"
    " * * * *\n"
    " * * *\n"
    " * *\n"
    " *\n" );
    std::string two( "2) abcdefgfedcba\n"
    " abcdefedcba\n"
    " abcdedcba\n"
    " abcdcba\n"
    " abcba\n"
    " aba\n"
    " a\n" );
    std::vector<std::string> Vec;
    Vec.push_back( one );
    Vec.push_back( two );
    for( std::size_t i(0); i < Vec.size(); ++i ){
    cout<< Vec.at( i ) <<std::endl;
    }
    cout<<std::endl;
    return 0;
    }

    You're welcome.
    <G>

    I expect you to send me $10.us for doing your homework!
     
    BobR, Jul 9, 2007
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.