Advertisement
Guest User

Zad 1

a guest
Aug 22nd, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. namespace exam
  7. {
  8.     class exam
  9.     {
  10.         static void Main()
  11.         {
  12.             int n = int.Parse(Console.ReadLine());
  13.  
  14.             double techMoney = 0.0;
  15.             double theorMoney = 0.0;
  16.             double practMoney = 0.0;
  17.  
  18.             for (int i = 0; i < n; i++)
  19.             {
  20.                 int dist = int.Parse(Console.ReadLine()) * 1600;
  21.                 double cargo = double.Parse(Console.ReadLine()) * 1000;
  22.                 string team = Console.ReadLine();
  23.                
  24.                 switch (team)
  25.                 {
  26.                     case "Technical":
  27.                         techMoney += cargo * 1.5 - 0.7 * dist * 2.5;
  28.                         break;
  29.                     case "Theoretical":
  30.                         theorMoney += cargo * 1.5 - 0.7 * dist * 2.5;
  31.                         break;
  32.                     case "Practical":
  33.                         practMoney += cargo * 1.5 - 0.7 * dist * 2.5;
  34.                         break;
  35.                 }              
  36.             }
  37.             List<double> result = new List<double>() { techMoney, theorMoney, practMoney};
  38.  
  39.             int maxIndex = -1;
  40.             double maxValue = int.MinValue;
  41.             int t = 0;
  42.             foreach (int v in result)
  43.             {
  44.                 if ((maxIndex < 0) || (v > maxValue))
  45.                 {
  46.                     maxValue = v;
  47.                     maxIndex = t;
  48.                 }
  49.                 t++;
  50.             }
  51.  
  52.             string teamPrint = "";
  53.             switch (maxIndex)
  54.             {
  55.                 case 0:
  56.                     teamPrint = "Technical";
  57.                     break;
  58.                 case 1:
  59.                     teamPrint = "Theoretical";
  60.                     break;
  61.                 case 2:
  62.                     teamPrint = "Practical";
  63.                     break;
  64.             }
  65.             Console.WriteLine($"The {teamPrint} Trainers win with ${maxValue:f3}.");
  66.          
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement