Advertisement
LePetitGlacon

FICHE 6.5 : Exercice 4

Nov 25th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace o
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             int[,] monTab2D = { { 1, 3, 5, 7 }, { 2, 4, 6, 8 }, { 3, 6, 9, 12 } };
  10.             int compteur = 0;
  11.             int nombremin = monTab2D[2,3];
  12.             int indicex = 0;
  13.             int indicey = 0;
  14.            
  15.             for(int iLig = 0; iLig <3 ; iLig ++)
  16.             {
  17.                 for(int iCol = 0; iCol <4 ; iCol ++, compteur++)
  18.                 {
  19.                     if (nombremin > monTab2D[iLig,iCol])
  20.                     {
  21.                         nombremin = monTab2D[iLig,iCol];
  22.                         indicex = iLig;
  23.                         indicey = iCol;
  24.                     }
  25.                 }
  26.             }
  27.             Console.WriteLine("Le plus petit des nombres du tableau est {0}",nombremin);
  28.             Console.WriteLine("Indice {0} {1}",indicex,indicey);
  29.             Console.ReadKey();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement