Const N=3; var a: array[1..N] of array[1..N] of integer; i,j,s:integer; begin s:=0; for i:=1 to N do begin for j:=1 to N do begin readln(a[i,j]); end; end; for i:=1 to N do begin if i mod 2 = 1 then for j:=1 to N do begin s:=s+a[i,j]; end; end; writeln(s); end.
vladburakoff5
20.12.2020
#include <iostream> #include <ctime> #include <stdlib.h> using namespace std;
double Sum(int *A, int N, int C, int M);
int main() { srand(time(0)); int N, C = 19, M = 30; cout << "N = ", cin >> N; int Train[N]; for(int i = 0; i < N; i++) cout << (Train[i] = rand() % (M+1)) << " "; cout << "\nSum = " << Sum(&Train[0], N, C, M);; return 0; }
double Sum(int*A, int N, int C, int M) { double S = 0; int k = 0; for(int i = 0; i < N; i++) { S += A[i]*C; k +=M - A[i]; } cout << "\nk = " << k; return S; }
testovich1012
20.12.2020
#include <iostream> #include <ctime> #include <stdlib.h> using namespace std;
double Sum(int *A, int N, int C, int M);
int main() { srand(time(0)); int N, C = 19, M = 30; cout << "N = ", cin >> N; int Train[N]; for(int i = 0; i < N; i++) cout << (Train[i] = rand() % (M+1)) << " "; cout << "\nSum = " << Sum(&Train[0], N, C, M);; return 0; }
double Sum(int*A, int N, int C, int M) { double S = 0; int k = 0; for(int i = 0; i < N; i++) { S += A[i]*C; k +=M - A[i]; } cout << "\nk = " << k; return S; }
Ответить на вопрос
Поделитесь своими знаниями, ответьте на вопрос:
Заполнить двумерный массив n*n числами с клавиатуры и найти сумму элементов массива нечётных столбцов
var a: array[1..N] of array[1..N] of integer;
i,j,s:integer;
begin
s:=0;
for i:=1 to N do begin
for j:=1 to N do begin
readln(a[i,j]);
end;
end;
for i:=1 to N do begin
if i mod 2 = 1 then
for j:=1 to N do begin
s:=s+a[i,j];
end;
end;
writeln(s);
end.