WHAT'S NEW?
Loading...
Pascal Triangle with C++
here the code to make Pascal triangle :
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int nJMLHBRS;
cin>>nJMLHBRS;
float nANGKA[nJMLHBRS][nJMLHBRS];
for (int i=0;i<nJMLHBRS;i++){
cout<<setw(4*(nJMLHBRS-i))<<" ";
for (int j=0;j<=i+1;j++){
if(j==0||j==i+1){nANGKA[i][0]=1;nANGKA[i][i+1]=1;}
else {nANGKA[i][j]=nANGKA[i-1][j]+nANGKA[i-1][j-1];}
if(j==0){cout<<nANGKA[i][j];}
else{cout<<setw(8)<<nANGKA[i][j];}
}
cout<<"\n";
}
return 0;
}
I use setw() from iomanip libary to make an triangle.
Caesars Palace Casino | DrmCD
ReplyDeleteCaesars Palace Casino. Dr. MGM Resorts has been in business since 광명 출장샵 1906. It's been 전라북도 출장샵 the official resort 하남 출장마사지 destination of 오산 출장마사지 the 익산 출장샵 Caesars Palace family.