Advertisement
levamurashev2002

Untitled

Jun 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp5
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] table = { 6, 10, 2, 4 };
  14. while (true)
  15. {
  16. Console.WriteLine("Все столы в зале:");
  17. for (int i = 0; i < table.Length; i++)
  18. {
  19. Console.WriteLine("Cтол № " + (i + 1) + " Свободных мест: " + table[i]);
  20. }
  21. Console.WriteLine("Какой стол вы хотите забронировать? ");
  22. int userTable = Convert.ToInt32(Console.ReadLine()) - 1;
  23. if(userTable > table.Length - 1)
  24. {
  25. Console.WriteLine("такого стола нет.");
  26. continue;
  27. }
  28.  
  29. Console.WriteLine("Сколько мест вым нужно? ");
  30. int userPlace = Convert.ToInt32(Console.ReadLine());
  31. if (table[userTable] >= userPlace && userPlace > 0)
  32. {
  33. table[userTable] -= userPlace;
  34. Console.WriteLine("Cпасибо за бронь!");
  35. }
  36. else
  37. Console.WriteLine("Недостаточно мест!");
  38.  
  39. Console.WriteLine("За столом " + (userTable + 1) + "Сейчас свободно " + table[userTable] + " Мест.");
  40. }
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement