Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Les3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] table = { 4, 4, 7, 4, 6, 5 };
- // теперь пользователь не видит столы за которыми не осталось мест
- while (true)
- {
- Console.Clear();
- for (int i = 0; i < table.Length; i++)
- {
- if (table[i] != 0)
- Console.WriteLine((i + 1) + " стол - свободных мест " + table[i]);
- }
- Console.WriteLine("Введите 0 чтобы выйти.");
- Console.Write("Введите номер стола:");
- int userInputTable = Convert.ToInt32(Console.ReadLine()) - 1;
- if (userInputTable == -1)
- break;
- if (userInputTable > table.Length - 1)
- {
- Console.Write("Такого стола нет.");
- Console.ReadKey();
- continue;
- }
- Console.Write("Введите кол-во мест:");
- int userInputPlace = Convert.ToInt32(Console.ReadLine());
- if (table[userInputTable] >= userInputPlace)
- table[userInputTable] -= userInputPlace;
- else
- {
- Console.WriteLine("За этим столом недостаточно мест.");
- Console.ReadKey();
- continue;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement