add program and gitignore

This commit is contained in:
2023-01-02 17:13:49 +03:00
parent 813253890d
commit d5c3f12816
3 changed files with 514 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
string[] array1 = {"1234", "1567", "-2", "computer science"};
string[] array2 = new string[array1.Length];
void Main()
{
Console.Write("Manual Input (1) or Presset (2): ");
int taskNumver = Convert.ToInt32(Console.ReadLine());
switch (taskNumver)
{
case 1:
Console.Write("Print size array: ");
int arraySize = Convert.ToInt32(Console.ReadLine());
Task(craeteMass(arraySize), array2);
PrintArray(array2);
break;
case 2:
Task(array1, array2);
PrintArray(array2);
break;
}
}
string[] craeteMass(int size)
{
string[] array = new string[size];
for (int i = 0; i < array.Length; i++)
{
Console.WriteLine($"Input {i+1} number: ");
array[i] = Console.ReadLine();
}
return array;
}
void Task(string[] array1, string[] array2)
{
int count = 0;
for (int i = 0; i < array1.Length; i++)
{
if(array1[i].Length <= 3)
{
array2[count] = array1[i];
count++;
}
}
}
void PrintArray(string[] array)
{
Console.WriteLine("Resault is: ");
for (int i = 0; i < array.Length; i++)
{
Console.Write($"{array[i]} ");
}
Console.WriteLine();
}
Main();