Top Menu

Selamat Datang di sedotgratis11.blogspot.com

Minggu, 01 April 2012

Membuat Program Segitiga Belah Ketupat (Tengahnya Bolong) C++


#include "iostream.h"
#include "conio.h"
//Created By: Rifky Raymond / sedotgratis11.blogspot.com

void main()
{
int a,b,c;
cout<<"input nilai : ";
cin>>c;
if(c==0)
c=c-1;
for(a=1;a<c;a++){
for(b=1;b<c;b++){
if((b+a==(c+1)/2)||(b+a==(((c-1)/2))+c))
cout<<"*";
else
if((b-a==((c+1)/2)-1)||(a-b==((c-1)/2)))
cout<<"*";
else
cout<<" ";}
cout<<"\n";
}
getch ();
}

2 komentar:

Related Posts Plugin for WordPress, Blogger...