Advertisement
RayanRam

NTM LE RETOUR

Dec 11th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. void affichage(int tab[][],int N,int M) /* Affichage des valeurs d'une matrice : N ligne, M colonne */
  7. {
  8.      int i,j;
  9. for(i=0;i<N;i++)
  10. {
  11. printf("Valeurs de la ligne %d : ",i+1);
  12.   for(j=0;j<M;j++)
  13.    {
  14.     printf(" %d |",tab[i][j]);
  15.    }
  16.      printf(" \n");
  17. }
  18. }
  19.                    
  20. int main()
  21. {
  22.   int N,M,j,i;
  23.   printf("Quelle est la largeur du tableau ? : ");
  24.   scanf("%d",&N);
  25.   printf("Quelle est sa hauteur ? : ");
  26.   scanf("%d",&M);
  27.   int tab[N+1][M+1];
  28.   for(i=0;i<N;i++)
  29.   {
  30.    for(j=0;j<M;j++) /*Remplissage*/
  31.    {
  32.      printf("Remplissez : \n");
  33.      scanf("%d",&tab[i][j]);
  34.    }
  35.   }
  36.   for(i=0;i<N;i++)   /* A la derniere colonne on veut affecter la somme de toute une ligne */
  37.   {
  38.   tab[i][M+1]=0;
  39.   for(j=0;j<M;j++)
  40.   {
  41.   tab[i][M+1]=tab[i][M+1]+tab[i][j];
  42. }
  43. }
  44.  
  45. for(j=0;j<M;j++) /* A la derniere ligne on affecte le max de chaque colonne */
  46. tab[N+1][j]=0;
  47. for(i=0;i<N;i++)
  48.   if (tab[i][j]>tab[i+1][j+1] && tab[i][j])
  49.   {
  50.     tab[N+1][j]=tab[i][j];
  51. }
  52. }
  53. }
  54. affichage(tab,N+1,M+1);
  55.   getchar();
  56.   system("PAUSE"); 
  57.   return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement