Составить алгоритм к программе - C#
Формулировка задачи:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int[] array = { 1, -2, 2, -4, 5, -6, 7, -8, 65 };
bool T = true;
if(array[0] == 0)
T = false;
else
for (int i = 1; i < array.Length ; i++)
{
if (array[i] != 0 && (-Math.Sign(array[i]) == Math.Sign(array[i - 1]))) continue;
T = false;
break;
}
Console.WriteLine("T={0}", T);
Console.ReadLine();Решение задачи: «Составить алгоритм к программе»
textual
Листинг программы
int[] array = { 1, -2, 2, -4, 5, -6, 7, -8, 65 };
int max = array[0];
for (int i = 1; i < array.Length; i++)
if (array[i] > max) max = array[i];
Console.WriteLine(max);