Sabtu, 02 April 2011

Program segitiga belah ketupat pada c++

#include
#include
#include

int n,i,j,x,y;

void main()
{
clrscr();
cout<<"masukkan bilangan: "; x=40 ; y=5;
cin>>n; gotoxy(x,y);
for (i=1; i<=n;i++)
{
for(j=1; j<=i;j++)
{
if(i==1)
{
cout << "=";
}
else if (j==1)
{
cout<<">";
}
else if (j==i)
{
cout<<" <";
}
else
{
cout<<" *";
}
delay(150);
}
x--; y++;
gotoxy(x,y);
}
for (i=n; i>=1;i--)
{
for(j=1; j<=i;j++)
{
if(i==1)
{
cout << " =";
}
else
{
cout<<" +";
}
delay(150);
}
x++; y++;
gotoxy(x,y);
}
getch();
}

2 komentar: