Program Segitiga Pascal (tanpa fungsi)
November 18, 2017Script Program:
#include <iostream.h>
#include <conio.h>
void main(){
int batas,a, i, k, j;
cout<<"masukkan batas : ";
cin>>batas;
for (i=0; i<=batas; i++){
for (k=0; k<=((2*batas)-(2*i)); k++){
cout<<" ";
}
for (j=0; j<=i; j++){
if (j==0||i==j){
a=1;
}else{
a=a*(i+1-j)/j;
}
cout<<" ";
cout<<a;
cout<<" ";
}
cout<<" ";
cout<<endl<<endl;
}
getch();
}
0 komentar