that_one_nigga_you_k

pascal quase lá

Jun 6th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. double fact(long n){
  7.     if(n == 1 || n==0){
  8.         return(1);
  9.     }
  10.  
  11.     else{
  12.         return(n*fact(n-1));  
  13.     }
  14.  
  15.   /*  else{
  16.         for(int i = 1; i <= n; ++i) {
  17.             n = n*i;
  18.         }
  19.  
  20.         return(n);
  21.     }  */
  22. }
  23.  
  24. long comb (int g, int e){
  25.  
  26.     int x;
  27.  
  28.     if(g>e) cout<<"deu ruim";
  29.  
  30.     x = fact(g)/(fact(e)*fact(g-e));
  31.    
  32.     return(x);
  33. }
  34.  
  35. void pir(int j){
  36.    
  37.     for(int i = 1; i<=j ; i++){
  38.  
  39.         for(int k = 1; k <= i; k++){
  40.             cout<< fact(j)/(fact(i)*fact(j-i)) <<"\t";
  41.         }
  42.  
  43.         cout<<"\n";
  44.     }
  45. }
  46.  
  47. int main(){
  48.    
  49.     pir(5);
  50.    
  51.     return(0);
  52. }
  53.  
Add Comment
Please, Sign In to add comment