Kamis, 02 Mei 2013

Widgets

Program Piramida Angka C++

Berikut adalah program piramida Angka menggunakan Borland C++. Semoga Bermanfaat


Sourcecode:

#include <iostream.h>
#include <conio.h>
void main()
{
int i,j,k;
cout<<"\n=================PROGRAM PIRAMIDA ANGKA=================";
cout<<"\n*                                            RENITHA ERDIANA                                                *";
cout<<"\n*                                                  110533430681                                                       *";
cout<<"\n===========================================================";
cout<<"\n";
cout<<"AngkaMaksimal dalam Diamon (1-9): ";
cin>>k;
clrscr();
for(i=1;i<=k;i++)
{
for(j=1;j<=k-i;j++)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
cout<<j;
}
for(j=i-1;j>=1;j--)
{
cout<<j;
}
cout<<endl;
}
for(i=k-1;i>=1;i--)
{
for(j=1;j=k-i;j++)
{
cout<<j;
}
for(j=i-1;j>=1;j--)
{
cout<<j;
}
cout<<endl;
}
getche();





Tampilan Printscreen :



0 komentar:

Posting Komentar