1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Bienvenue veut-tu commencer ce programme <oui> ou <non>");
string choix, str_Recommencer;
choix = Console.ReadLine();
do //Début de la boucle de recommencement
{
if (choix == "non" || choix == "Non" || choix == "NON")
{
Environment.Exit(0);
}
else
{
}
int u, i, PG, IPG; //Déclaration des variables
string N;
IPG = PG = 0;
Console.WriteLine("Veuillez saisir 20 nombres succèsivement : ");
for (i = 1; i <= 20; i++) //Boucle de 1 à 20
{
Console.Write("Saisie: ");
N =Console.ReadLine(); //Lecture
int.TryParse(N, out u);
if (i == 1 || u > PG) //Si
{
PG = u;
IPG = i;
}
}
Console.WriteLine("Le nombre le plus grand était: " + PG);
Console.WriteLine("Il a été saisi en position numéro: " + IPG);
Console.ReadKey();
Console.Write("\n\nVoulez-vous recommencer ? (o / n) :"); //On demande à l'utilisateur si il veut recommencer le programme
str_Recommencer = Console.ReadLine(); //On lit la reponse de l'utilisateur
}
while (str_Recommencer == "oui" || str_Recommencer == "o");
//Si l'utilisateur répond oui, on recommence le programme
}
}
} |
Partager