Tuesday 20 January 2015

Contoh script c++ bentuk wajik

#include <iostream.h>
#include <conio.h>
main()
{
int n;
int baris;
int kolom;
cout<<"--------------"<<endl;
cout<<"Program by: AULIYA RAHMAH"<<endl;
cout<<"--------------"<<endl;
cout<<endl;
cout<<"Masukkan jumlah bintang : ";
cin>>n;
cout<<endl;
for(baris=1; baris<=n; baris++)
{
for(kolom=baris; kolom<=n-1; kolom++)
cout<<" ";
for(kolom=n-baris; kolom<=n-1; kolom++)
cout<<"*";
for(kolom=1; kolom<=baris-1; kolom++)
cout<<"*";
cout<<endl;
}
for(baris=1; baris<=n; baris++)
{
for(kolom=1; kolom<=baris-1; kolom++)
cout<<" ";
for(kolom=baris; kolom<=n; kolom++)
cout<<"*";
for(kolom=baris; kolom<=n-1; kolom++)
cout<<"*";
cout<<endl;
}
getch();
}

Download script Link1 / Link2

No comments:

Post a Comment