Advertisement
SLENSER

кафе

May 19th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. namespace Les3
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             int[] table = { 4, 4, 7, 4, 6, 5 };
  8.  
  9.             while (true)
  10.             {
  11.                 Console.Clear();
  12.  
  13.                 int tables = table.Sum();
  14.  
  15.                 Console.WriteLine("Всего свободных мест " + tables);
  16.                 for (int i = 0; i < table.Length; i++)
  17.                 {
  18.                     Console.WriteLine((i + 1) + " стол - свободных мест " + table[i]);
  19.                 }
  20.                 Console.WriteLine("Введите 0 чтобы выйти.");
  21.  
  22.                 Console.Write("Введите номер стола:");
  23.                 int userInputTable = Convert.ToInt32(Console.ReadLine()) - 1;
  24.  
  25.                 if (userInputTable == -1)
  26.                     break;
  27.  
  28.                 if (userInputTable > table.Length - 1)
  29.                 {
  30.                     Console.Write("Такого стола нет.");
  31.                     Console.ReadKey();
  32.                     continue;
  33.                 }
  34.  
  35.  
  36.                 Console.Write("Введите кол-во мест:");
  37.                 int userInputPlace = Convert.ToInt32(Console.ReadLine());
  38.                 if(userInputPlace < 0)
  39.                 {
  40.                     continue;
  41.                 }
  42.  
  43.                 if (table[userInputTable] >= userInputPlace) {    
  44.                     table[userInputTable] -= userInputPlace;
  45.                 }
  46.                 else
  47.                 {
  48.                     Console.WriteLine("За этим столом недостаточно мест.");
  49.                     Console.ReadKey();
  50.                     continue;
  51.                 }
  52.             }
  53.  
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement