Advertisement
Guest User

Untitled

a guest
Sep 12th, 2019
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _5._Seats
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. int numOfTickets = int.Parse(Console.ReadLine());
  10.  
  11. for (int i = 1; i <= numOfTickets; i++)
  12. {
  13. string ticket = Console.ReadLine();
  14. int ticketToNum = int.Parse(ticket.ToString());
  15.  
  16. char firstDigit = ticket[0];
  17. char secondDigit = ticket[1];
  18. char thirdDigit = ticket[2];
  19. char fourthDigit = ticket[3];
  20.  
  21. bool condition = firstDigit >= 'A' && firstDigit <= 'Z';
  22.  
  23. if (numOfTickets == 4)
  24. {
  25. if (condition)
  26. {
  27. Console.WriteLine($"Seat decoded: {firstDigit}{secondDigit}{thirdDigit}");
  28. }
  29.  
  30. else
  31. {
  32. Console.WriteLine($"Seat decoded: {fourthDigit}{secondDigit}{thirdDigit}");
  33. }
  34. }
  35.  
  36. else if (numOfTickets == 5 || numOfTickets == 6)
  37. {
  38. //char digit = char.Parse(secondDigit.ToString());
  39. char ASCIIDigit = (char)secondDigit;
  40. Console.WriteLine($"Seat decoded: {firstDigit}{ASCIIDigit}");
  41. }
  42.  
  43.  
  44. }
  45.  
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement