Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- long fact(long n){
- long h = 1;
- if(n == 1 || n==0){
- return(1);
- }
- else{
- for(int i = 1; i <= n; ++i) {
- h *= i;
- }
- return(h);
- }
- }
- long comb (int g, int e){
- int r;
- if(e>g) cout<<"deu merda";
- r=fact(g)/(fact(e)*fact(g-e));
- return(r);
- }
- void gerar(int t){
- for(int i = 1; i <= t; ++i) {
- for(int j = 0; j <= i; ++j) {
- cout << comb(i, j)<<"\t";
- }
- cout << "\n";
- }
- }
- int main(){
- int l,h,t;
- gerar(6);
- return(0);
- }
Add Comment
Please, Sign In to add comment