View Single Post
Old 11-25-2004, 04:27 AM   #4 (permalink)
slvrstang
 
Ultra Techie

Join Date: Oct 2003

Posts: 750

slvrstang is on a distinguished road

Send a message via AIM to slvrstang
Default

try this

#include <iostream>
using namespace std;

int x;
int i;
int j;

void main(void)
{

cout << "Please input X";
cin >> x;
for(i=1;i<=x;i++)
{
for(j=1;j<=i;j++)
{
cout<<"*";
}
cout<<endl;
}
i--;
for(;i>0;i--)
{
for(j=1;j<i;j++)
{
cout<<"*";
}
cout<<endl;
}
}


It defaults to * but you could change it

just add the char in the declarations and replace * with the char

like this

#include <iostream>
using namespace std;

int x;
int i;
int j;
char cha;

void main(void)
{

cout << "\nPlease input X: \n";
cin >> x;
cout << "\nPlease input a character: \n";
cin >> cha;
for(i=1;i<=x;i++)
{
for(j=1;j<=i;j++)
{
cout << cha;
}
cout<<endl;
}
i--;
for(;i>0;i--)
{
for(j=1;j<i;j++)
{
cout << cha;
}
cout<<endl;
}
}

Just make it a little prettier and your set
__________________

Q6600 G0 @ 3.80ghz
MCR-320-->Dtek Fuzion V2-->Dtek Fuzion GFX2-->Swiftech MCP-655-->
Asus P5K deluxe
4x1gb Crucial Ballistix @ 846mhz 5-5-5-15
8800GT
3x 250gb HDDs
Hiper 580w
Coolermaster 690 w/ water cooling mods
3dmark06 - 15,602
SuperPi 1M - 12.421s
slvrstang is offline