Tuesday, 20 January 2015

Contoh script c++ input jumlah bintang

#include <iostream.h>
int main()
{
int jml_bintang;
cout<<"--------------"<<endl;
cout<<"Program by: Auliya Rahmah"<<endl;
cout<<"auliyarahmah@rocketmail.com"<<endl;
cout<<"--------------"<<endl;
cout<<endl;
cout<< "Masukkan jumlah bintang: ";
cin>>jml_bintang;
cout<<endl;
int x;
int y;
for (x=0; x<jml_bintang; x++)
{
for (y=0; y<=x; y++)
{
cout<<'1';
};
cout<<endl;
};
for (x=jml_bintang-2; x>=0; x-- )
{
for (y=0; y<=x; y++)
{
cout<<'2';
};
cout<<endl;
};
return 0;
}

Download script Link1 / Link2

No comments:

Post a Comment