Update Lesson 1 Task 3

This commit is contained in:
Stanislav Mykhailenko 2023-03-19 14:03:57 +02:00
parent 62266346ac
commit 49969a1b5f
GPG key ID: 1E95E66A9C9D6A36

View file

@ -11,18 +11,22 @@ for (int i = 0; i < 10; i++)
{ {
int newNumber; int newNumber;
do while (true)
{ {
Console.Write($"Enter number {i + 1}: "); Console.Write($"Enter number {i + 1}: ");
} while (!int.TryParse(Console.ReadLine(), out newNumber)); if (int.TryParse(Console.ReadLine(), out newNumber))
break;
}
numbers.Add(newNumber); numbers.Add(newNumber);
} }
do while (true)
{ {
Console.Write("Enter a number to duplicate: "); Console.Write($"Enter number to duplicate: ");
} while (!int.TryParse(Console.ReadLine(), out duplicate)); if (int.TryParse(Console.ReadLine(), out duplicate))
break;
}
for (int i = 0; i < numbers.Count; i++) { for (int i = 0; i < numbers.Count; i++) {
if (numbers[i] == duplicate) if (numbers[i] == duplicate)