Advertisement
LePetitGlacon

FICHE 7 Exercice 5

Dec 4th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace u
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Temps min, sec");
  10.             int minute = int.Parse(Console.ReadLine());
  11.             int seconde = int.Parse(Console.ReadLine());
  12.             Console.WriteLine("Nombre obstacle touché ?");
  13.             int nbTouché = int.Parse(Console.ReadLine());
  14.             Console.WriteLine("Nombre obstacle renversé ?");
  15.             int nbCouché = int.Parse(Console.ReadLine());
  16.  
  17.             int tempsFinale = tempsParcours(minute, seconde, nbTouché, nbCouché);
  18.  
  19.             Console.WriteLine("Votre temps après soustraction des fautes est {0}",tempsFinale);
  20.             Console.ReadLine();
  21.         }
  22.  
  23.         /// < summary>
  24.         /// Calcule en seconde le temps d'un parcours en intégrant les pénalités
  25.         /// < /summary>
  26.         /// < param name="minute">< /param>
  27.         /// < param name="seconde">< /param>
  28.         /// < param name="nbTouché">< /param>
  29.         /// < param name="nbCouché">< /param>
  30.         /// < returns>le temps en seconde pénalités incluses< /returns>
  31.  
  32.         static int tempsParcours(int minute, int seconde, int nbTouché, int nbCouché)
  33.         {
  34.             seconde = seconde + (60 * minute);
  35.             seconde = seconde - (-5 * nbTouché + -10 * nbCouché);
  36.             //minute = seconde / 60;
  37.             //seconde = seconde % 60;
  38.             return seconde;
  39.         }
  40.     }
  41. }
  42. ---------------------------------------------------------------------------------------
  43. using System;
  44.  
  45. namespace u
  46. {
  47.     class Program
  48.     {
  49.         public static void Main(string[] args)
  50.         {
  51.             {
  52.  
  53.                 int nbParticipants;
  54.                 Console.WriteLine("Combien avez vous de participants ?");
  55.                 nbParticipants = int.Parse(Console.ReadLine());
  56.                 int[] tempsParticipant = new int[nbParticipants];
  57.                 int meilleurJoueur = 1500;
  58.                 int meilleurIndice = 1500;
  59.  
  60.                 for (int i = 0; i < tempsParticipant.Length; i++)
  61.                 {
  62.                     tempsParticipant[i] = FonctionSaisieEtCalculTemps(i,0);
  63.                     if (meilleurJoueur > tempsParticipant[i])
  64.                     {
  65.                         meilleurJoueur = tempsParticipant[i];
  66.                         meilleurIndice = i+1;
  67.                     }
  68.                 }
  69.  
  70.  
  71.  
  72.                 Console.WriteLine("Temps des participants :");
  73.  
  74.                 for (int i = 0; i < tempsParticipant.Length; i++)
  75.                 {
  76.                     Console.WriteLine("Participant {0} : {1} secondes", i+1, tempsParticipant[i]);
  77.                 }
  78.                 Console.WriteLine("Le meilleur participant est n° {0} avec {1} secondes", meilleurIndice,meilleurJoueur);
  79.  
  80.             }
  81.             Console.ReadLine();
  82.         }
  83.  
  84.         /// < summary>
  85.         /// Calcule en seconde le temps d'un parcours en intégrant les pénalités
  86.         /// < /summary>
  87.         /// < param name="minute">< /param>
  88.         /// < param name="seconde">< /param>
  89.         /// < param name="nbTouché">< /param>
  90.         /// < param name="nbCouché">< /param>
  91.         /// < returns>le temps en seconde pénalités incluses< /returns>
  92.  
  93.         static int tempsParcours(int minute, int seconde, int nbTouché, int nbCouché)
  94.         {
  95.             seconde = seconde + (60 * minute);
  96.             seconde = seconde - (5 * nbTouché + 10 * nbCouché);
  97.             //minute = seconde / 60;
  98.             //seconde = seconde % 60;
  99.             return seconde;
  100.         }
  101.  
  102.         /// <summary>
  103.         /// Saisie les valeurs utilisateur et calcule le temps
  104.         /// </summary>
  105.         /// <param name="i"></param>
  106.         /// <returns>Le temps en seconde des pénalités incluse</returns>
  107.         static int FonctionSaisieEtCalculTemps(int i,int a)
  108.         {
  109.             Console.WriteLine("Participant {0}", i+1);
  110.             Console.WriteLine("Temps min, sec");
  111.             int minute = int.Parse(Console.ReadLine());
  112.             int seconde = int.Parse(Console.ReadLine());
  113.             Console.WriteLine("Nombre obstacle touché ?");
  114.             int nbTouché = int.Parse(Console.ReadLine());
  115.             Console.WriteLine("Nombre obstacle renversé ?");
  116.             int nbCouché = int.Parse(Console.ReadLine());
  117.             a = tempsParcours(minute, seconde, nbTouché, nbCouché);
  118.             return a;
  119.         }
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement