c#: Correction des exercices tableaux et matrices 1_2_3
c#: Correction des exercices tableaux et matrices 1_2_3
- Enoncé Exercice 1_2_3
- Correction Exercice 1_2_3
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace exrcicie_1_2_3 { class Program { static void Main(string[] args) { exercice1(); exercice2(); exercice3(); } private static void exercice1() { int[] tableau=new int[3]; Nullablemin=null; for (int i = 0; i < 3; i++) { System.Console.WriteLine("Saisir l'entier {0}",i+1); tableau[i] =Convert.ToInt16( System.Console.ReadLine()); } //Recherche de minimum for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (min > tableau[j]) min = tableau[j]; } } Console.WriteLine("Le minimum est: " + min + " "); } private static void exercice2() { int[] tab = new int[26 - 5]; Random rnd = new Random(); // affectation de valeurs entières, pris au hasard entre 5 et 10, au tableau for (int i = 0; i < 26 - 5; i++) { tab[i] = rnd.Next(5, 26); } //affichage des valeurs du tableau for (int i = 0; i < 26 - 5; i++) { Console.WriteLine(tab[i] + " "); } Console.ReadLine(); } private static void exercice3() { char[] alphabet = new char[26]; for (int i = 0; i < 26; i++) { alphabet[i] = Convert.ToChar(65 + i); } for (int i = 0; i < 26; i++) { Console.WriteLine(alphabet[i]); } } } }