Const n = 13; Type Mass = array[1..n] of real; Function KL(Var A:Mass; c:real):integer; Var k,i:integer; Begin k:=0; For i:= 1 to n do if A[i] > c then k:=k+1; KL:=k; End; Var A:Mass; i:integer; c:real; Begin Randomize; Write('A(',n,'):'); For i:= 1 to n do Begin A[i]:=random*21-10; Write(' ',A[i]:0:3); End; WriteLn; Write('c = ');ReadLn(c); WriteLn('k = ',KL(A,c)) End.
Пример работы программы:
A(13): -2.768 10.516 -3.518 9.286 5.555 1.039 1.225 -6.135 8.743 7.440 -3.979 6.129 -7.982 c = 3 k = 6
namespace Matrix
{
class MainClass
{
private static int size; // Размер матрицы
public static void Main (string[] args)
{
size = Int16.Parse(Console.ReadLine ());
int[,] matrix = new int[size, size];
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (i == 0 || j == 0 || i == (size - 1) || j == (size - 1)){
matrix [i, j] = 1;
} else {
matrix [i, j] = 0;
}
}
}
/*for (int i = 0; i < size; i++) { // Вывод матрицы в консоль
for (int j = 0; j < size; j++) {
Console.Write (matrix [i, j]);
}
Console.WriteLine ();
}*/
}
}
}
Const
n = 13;
Type
Mass = array[1..n] of real;
Function KL(Var A:Mass; c:real):integer;
Var
k,i:integer;
Begin
k:=0;
For i:= 1 to n do
if A[i] > c then k:=k+1;
KL:=k;
End;
Var
A:Mass;
i:integer;
c:real;
Begin
Randomize;
Write('A(',n,'):');
For i:= 1 to n do
Begin
A[i]:=random*21-10;
Write(' ',A[i]:0:3);
End;
WriteLn;
Write('c = ');ReadLn(c);
WriteLn('k = ',KL(A,c))
End.
Пример работы программы:
A(13): -2.768 10.516 -3.518 9.286 5.555 1.039 1.225 -6.135 8.743 7.440 -3.979 6.129 -7.982
c = 3
k = 6