VladoG

PB-BG-Oct2018-ExamPrep-06.TicketCombination

Nov 24th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.TicketCombination
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int combinationNum = int.Parse(Console.ReadLine());
  10.  
  11.             int counter = 0;
  12.             //int counterTest = 0;
  13.  
  14.             for (char firstPosition = 'B'; firstPosition <= 'L'; firstPosition++)
  15.             {
  16.                 for (char secondPosition = 'f'; secondPosition >= 'a'; secondPosition--)
  17.                 {
  18.                     for (char thirdPosition = 'A'; thirdPosition <= 'C'; thirdPosition++)
  19.                     {
  20.                         for (int fourthPosition = 1; fourthPosition <= 10; fourthPosition++)
  21.                         {
  22.                             for (int fifthPosition = 10; fifthPosition >= 1; fifthPosition--)
  23.                             {
  24.                                 //counterTest++;
  25.                                 if (firstPosition % 2 == 0)
  26.                                 {
  27.                                     counter++;
  28.                                 }
  29.                                 if (counter == combinationNum)
  30.                                 {
  31.                                     Console.WriteLine($"Ticket combination: {firstPosition}{secondPosition}{thirdPosition}{fourthPosition}{fifthPosition}");
  32.                                     int price = firstPosition + secondPosition + thirdPosition + fourthPosition + fifthPosition;
  33.                                     Console.WriteLine($"Prize: {price} lv.");
  34.                                     break;
  35.                                 }
  36.                                 //Console.WriteLine(counterTest);
  37.                             }
  38.                             if (counter == combinationNum)
  39.                             {
  40.                                 break;
  41.                             }
  42.                         }
  43.                         if (counter == combinationNum)
  44.                         {
  45.                             break;
  46.                         }
  47.                     }
  48.                     if (counter == combinationNum)
  49.                     {
  50.                         break;
  51.                     }
  52.                 }
  53.                 if (counter == combinationNum)
  54.                 {
  55.                     break;
  56.                 }
  57.             }
  58.         }
  59.     }
  60. }
Add Comment
Please, Sign In to add comment