mirror of
https://github.com/svek95/programming_GB.git
synced 2026-05-17 18:41:44 +03:00
add HW4
This commit is contained in:
+31
@@ -121,6 +121,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
public int Task_27(int number)
|
||||
{
|
||||
if (number == 0)
|
||||
return 0;
|
||||
else
|
||||
return number % 10 + Task_27(number / 10);
|
||||
}
|
||||
|
||||
public void Task_29(int size)
|
||||
{
|
||||
int[] array = new int[size];
|
||||
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
Console.WriteLine($"Input {i} number to array");
|
||||
int number = Convert.ToInt32(Console.ReadLine());
|
||||
array[i] = number;
|
||||
}
|
||||
|
||||
/// Ввод рандомных элементов массива
|
||||
/* Random myRandom = new Random();
|
||||
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i] = myRandom.Next(0, 100000); /// чтобы цифры были не over99999
|
||||
// Console.Write("{0} ", array[i]);
|
||||
}*/
|
||||
|
||||
Console.WriteLine("Array is: " + "[{0}]", string.Join(", ", array));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,3 +16,8 @@
|
||||
## HW3
|
||||
- [X] Task_19
|
||||
- [X] Task_23
|
||||
|
||||
|
||||
## HW4
|
||||
- [X] Task_27
|
||||
- [X] Task_29
|
||||
|
||||
@@ -74,6 +74,15 @@ public class Start
|
||||
PrintNumberConsole();
|
||||
HW.Task_23(ReadIntNumber());
|
||||
break;
|
||||
case 27:
|
||||
PrintNumberConsole();
|
||||
Console.WriteLine("Resault is: " + HW.Task_27(ReadIntNumber()));
|
||||
break;
|
||||
case 29:
|
||||
Console.WriteLine("Length for array: ");
|
||||
HW.Task_29(ReadIntNumber());
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Console.WriteLine("Wrong task");
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user