Advertisement
RayanRam

Le code de mort

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