looping problems...

T

tanmay

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...
 
R

RGambord

[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
thankyou very much for solving my problem...

No problem! Our pleasure!

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.
 
R

RGambord

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.
 
B

BobR

tanmay said:
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...

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!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top