Wpisz frazę i naciśnij Enter. Esc zamyka.

Program przepisujący dodatnie liczby w C#

Console.WriteLine("Podaj rozmiar tablicy: ");
int n = int.Parse(Console.ReadLine());
int[] t1 = new int[n];
int[] t2 = new int[n];
for (int i = 0; i < n; i++)
{
Console.WriteLine("Podaj liczbę : {0}", i);
t1[i] = int.Parse(System.Console.ReadLine());
if (t1[i] > 0)
{
t2[i] = t1[i];
}
else
{
t1[i] = 0;
}
}
for (int i = 0; i < n; i++)
{
Console.Write(t2[i] + " ");
}

Console.ReadKey();

Console.ReadKey();

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Wymagane pola są oznaczone *