HELP!!! printing geometic figures horizontally

b_barbar

Beta member
Messages
1
help!!!
After solving this problem, I can not print it horizontally. What is the correct cout string? I have tried to use setw and '\t'.
Thanks

#include <iostream.h>
#include <iomanip.h>
int main()
{
cout
<<setw(10)<<1
<<setw(10)<<2
<<setw(10)<<3
<<setw(10)<<4
<<setw(10)<<5
<<setw(10)<<6
<<setw(10)<<7

<<endl;

cout<<"123456789012345678901234567890123456789012345678901234567890"<<
"1234567890"<<endl;

cout<<"(A)"<<setw(15)<<"(B)"<<setw(15)<<"(C)"<<setw(15)<<"(D)\n";

{
for (int i=0; i<=10; ++i)
{for (int j=1; j<=i+1; j++)
cout<<'*';
cout<<endl;
}}

for (int i=1; i<=10; i++)

{for (int j=1; j<=11-i; j++)
cout<<'*';
cout<<endl;
}
for (int i=1; i<=10; i++)
{
for (int j=0; j< 10 ; j++)
cout << (j < i-1 ? ' ' : '*');
cout<<endl;
}
for (int i=0; i<=10; i++)
{for (int j=0; j<=10; j++)
cout<<(j<10-i? ' ' : '*');
cout<<endl;
}
return 0;
}
<pegasus> g++ test.cpp
<pegasus> a.out
*
**
***
****
*****
******
*******
********
*********
**********
***********
**********
*********
********
*******
******
*****
****
***
**
*
**********
*********
********
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
********
*********
**********
***********
 
Back
Top Bottom