Advertisement
Arfizato

factoriel for my baby

May 20th, 2022
876
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.  
  6.     int n,m;
  7.     int i,j;
  8.     int mat[50][50];
  9.     int f[50][50];
  10.     /*write a program that fills a matrix of integers
  11.     M of size ( n*m) and then calculates the sum and product
  12.     of each column and puts it in respective arrays S and P*/
  13.  
  14.     printf("donner les dimension :\t");
  15.     scanf ("%d %d",&n,&m);
  16.  
  17.  
  18.     for (i=0; i<n; i++)
  19.     {
  20.         for (j=0; j<m; j++)
  21.         {
  22.             printf("mat[%d][%d] : ",i,j);
  23.             scanf("%d",&mat[i][j]);
  24.         }
  25.     }
  26.  
  27.  
  28.     printf("**Matrice donnée**:\n");
  29.     for (i=0; i<n; i++)
  30.     {
  31.         for (j=0; j<m; j++)
  32.         {
  33.             printf("%d ",mat[i][j]);
  34.         }
  35.         printf("\n");
  36.     }
  37.  
  38.     printf("**Matrice Factorielle**:\n");
  39.     for( i=0;i<n;i++){
  40.         for(j=0;j<m;j++){
  41.                 //boucle hedhi te7seb el factoriel
  42.                 f[i][j]=1;
  43.                 for (int a=mat[i][j];a>0;a--){
  44.                     f[i][j]=a*f[i][j];
  45.                 }
  46.                 printf("%d\t",f[i][j]);
  47.         }
  48.         printf("\n");
  49.     }
  50.  
  51.  
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement