Составить программу вычисления функции y(x)или z(t)в n равномерно распределенных точках диапазона x1< =x< =2 или z1< =z< =z2. выполнять с использованием цикла while и repeat
1. a = 10; b = 5; not (a < 5) -> not (5 < 5) -> not false -> true -> a = 5 ответ: 5
2. a = 10; b = 5; (a > 5) and (a < b) -> (10 > 5) and (10 < 5) -> true and false -> false ответ: 10
3. a = 10; b = 5; (a > 1) or (a < b) -> (10 > 1) or (10 < 5) -> true or false -> true -> a = a-5 = 10-5 = 5 (a > 1) and (a = b) -> (5 > 1) and (5 = 5) -> true and true -> true -> a = a-5 = 5-5 = 0 ответ: 0
4. a = 10; b = 5; (a > 1) and (a < b) -> (10 > 1) and (10 < 5) -> true and false -> false (a > 1) and (a = b) -> (10 > 1) and (10 = 5) -> true and false -> false ответ: 10
5. a := 10; b := 5; (a > 1) and (a < b) -> (10 > 1) and (10 < 5) -> true and false -> false -> a = a + 7 = 10+7 = 17 ответ: and
6. a = 10; b := 5; (a < 1) or (a > b) -> (10 < 1) or (10 > 5) -> a = a-7 = 10-7 = 3 ответ: or
7. a = 10; b = 5; (a < 1) and (a > b) -> (10 < 1) and (10 > 5) -> false and true -> false -> a = a + 5 = 10+5 = 15 ответ: and
class Program
{
static void Main()
{
var random = new Random(DateTime.Now.Millisecond);
int n = 3;
var f = new int[n, n];
int c;
Console.WriteLine("f:");
for (var i = 0; i < n; i++)
{
for (var j = 0; j < n; j++)
{
f[i, j] = random.Next(0, 9);
Console.Write(f[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
for(int i = 0; i < n; i++) {
if (f[i,0] != f[i,i]){
c = f[i,0]; f[i,0] = f[i,i]; f[i,i] = c;
}
}
Console.WriteLine("New f:");
for(int i = 0; i < n; i++){
for (var j = 0; j < n; j++)
Console.Write(f[i,j] + " ");
Console.WriteLine();
}
Console.WriteLine();
Console.ReadKey();
}
}
Пример:
f:
8 1 0
3 6 3
0 5 7
New f:
8 1 0
6 3 3
7 5 0
not (a < 5) -> not (5 < 5) -> not false -> true -> a = 5
ответ: 5
2. a = 10; b = 5;
(a > 5) and (a < b) -> (10 > 5) and (10 < 5) -> true and false -> false
ответ: 10
3. a = 10; b = 5;
(a > 1) or (a < b) -> (10 > 1) or (10 < 5) -> true or false -> true -> a = a-5 = 10-5 = 5
(a > 1) and (a = b) -> (5 > 1) and (5 = 5) -> true and true -> true -> a = a-5 = 5-5 = 0
ответ: 0
4. a = 10; b = 5;
(a > 1) and (a < b) -> (10 > 1) and (10 < 5) -> true and false -> false
(a > 1) and (a = b) -> (10 > 1) and (10 = 5) -> true and false -> false
ответ: 10
5. a := 10; b := 5;
(a > 1) and (a < b) -> (10 > 1) and (10 < 5) -> true and false -> false -> a = a + 7 = 10+7 = 17
ответ: and
6. a = 10; b := 5;
(a < 1) or (a > b) -> (10 < 1) or (10 > 5) -> a = a-7 = 10-7 = 3
ответ: or
7. a = 10; b = 5;
(a < 1) and (a > b) -> (10 < 1) and (10 > 5) -> false and true -> false -> a = a + 5 = 10+5 = 15
ответ: and