Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Les3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] table = { 4, 4, 7, 4, 6, 5 };
- while (true)
- {
- Console.Clear();
- int tables = table.Sum();
- Console.WriteLine("Всего свободных мест " + tables);
- for (int i = 0; i < table.Length; i++)
- {
- 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(userInputPlace < 0)
- {
- continue;
- }
- if (table[userInputTable] >= userInputPlace) {
- table[userInputTable] -= userInputPlace;
- }
- else
- {
- Console.WriteLine("За этим столом недостаточно мест.");
- Console.ReadKey();
- continue;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement