Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 08-28-2003, 01:47 AM   #1
Beta Member
 
Join Date: Aug 2003
Posts: 1
Question HELP!!! printing geometic figures horizontally

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<<"1234567890123456789012345678901234567890123 45678901234567890"<<
"1234567890"<<endl;

cout<<"(A)"<<setw(15)<<"(B)"<<setw(15)<<"(C)"<<set w(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
*
**
***
****
*****
******
*******
********
*********
**********
***********
**********
*********
********
*******
******
*****
****
***
**
*
**********
*********
********
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
********
*********
**********
***********
b_barbar is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 12:15 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0