PROGRAM DEV C++
#include <iostream>#include <conio.h>
using namespace std;
int main()
{
int x,y,a,b,c,d;
cout << "Silahkan anda masukan jumlah bintang yang anda inginkan = "; cin >> x;
cout<<endl;
cout<<"Segitiga pertama"<<endl;
for (a = 1; a <= x; a++)
{
b = x - a;
for ( c = 1; c <= b; c++)
{
cout << " ";
}
for ( d = 1; d <= a; d++)
{
cout << "*";
}
cout << endl;
}
cout<<endl;
cout<<"Segitiga kedua"<<endl;
b = x;
for (y = 1; y <= x; y++)
{
for (a=1; a <= b; a++)
{
cout << "*";
}
cout << endl;
b--;
}
cout<<endl;
cout<<"Segitiga ketiga"<<endl;
for (a=1; a<=x; a++)
{
for (b=1; b<=a; b++)
{
cout<<"*";
}
cout<<endl;
}
cout<<endl;
cout<<"Segitiga keempat"<<endl;
for (a = 1; a <= x; a++)
{
b = x - a;
for ( c = 1; c <= a; c++)
{
cout << " ";
}
for ( d = 1; d <= b; d++)
{
cout << "*";
}
cout << endl;
}
getch();
}
Selamat Mencoba :)
No comments:
Post a Comment