Jump to content
СофтФорум - всё о компьютерах и не только

Подпрограммы паскаль


Recommended Posts

НЕ понимаю как сделать помогите сделать задание!

1.вычисление количества положительных элементов в четных строках матрицы

2.вычисление сумм положительных и отрицательных элементов и количество отдельных элементов матриц

Link to comment
Share on other sites

nolx:

Для таких вопросов есть специальная тема, помеченная как Важная: Заказы "Сделайте все за меня", А вдруг прокатит?

НЕ понимаю как сделать
Перебирать элементы и добавлять в какую-нибудь переменную по единице, когда элемент соответствует условию.
var a:array[1..20,1..20]of integer; i,j,n,m,p,r:integer;beginwrite('N M ? '); readln(n,m);randomize; for i:=1 to n do for j:=1 to m do a[i,j]:=random(199)-99;for i:=1 to n do begin for j:=1 to m do write(a[i,j]:4); writeln end;p:=0; for i:=1 to n div 2 do for j:=1 to m do if a[2*i,j]>0 then inc(p);writeln('positiv: ',p);p:=0; r:=0; for i:=1 to 10 do for j:=1 to 10 do  begin if a[i,j]>0 then p:=p+a[i,j]; if a[i,j]<0 then r:=r+a[i,j]; end;Writeln('sum positiv: ',p,'   sum negativ: ',r,'   number: ',m*n); readlnend.
Link to comment
Share on other sites

nolx:

А потом еще что-нибудь вспомнится?

var a:array[1..20,1..20]of integer; i,j,n,m,p,r:integer;procedure pr; var i,j: integer; begin p:=0; r:=0; for i:=1 to 10 do for j:=1 to 10 do  begin if a[i,j]>0 then p:=p+a[i,j]; if a[i,j]<0 then r:=r+a[i,j]; end; end; function fu:integer; var p,i,j:integer;begin p:=0; for i:=1 to n div 2 do for j:=1 to m do if a[2*i,j]>0 then inc(p); fu:=p; end;beginwrite('N M ? '); readln(n,m);randomize; for i:=1 to n do for j:=1 to m do a[i,j]:=random(199)-99;for i:=1 to n do begin for j:=1 to m do write(a[i,j]:4); writeln end;writeln('positiv: ',fu); pr; Writeln('sum positiv: ',p,'   sum negativ: ',r,'   number: ',m*n); readlnend.
  • Upvote 1
Link to comment
Share on other sites

нужно решить по этой программе замените по заданию:

1.вычисление количества положительных элементов в четных строках матрицы

2.вычисление сумм положительных и отрицательных элементов и количество отдельных элементов матриц

Program Procedur;

uses crt;

type

matr=array [1..5,1..5] of integer;

const

A: matr= ((1,2,5,5,3),

(1, 3, 4, 5, 3),

(6, 7, 4, 6, 8),

(4, 6, 8, 4, 8),

(9, 6, 4, 9, 7));

var

i,j:integer;

b:matr;

function element(const m:matr):integer;

var

max:integer;

begin

clrscr;

for i:=1 to 5 do

for j:=1 to 5 do

if m[i,j] mod 3=0 then max:=m[i,j];

for i:=1 to 5 do

for j:=1 to 5 do

if (m[i,j] mod 3=0)and (m[i,j]>max) then max:=m[i,j];

element:=max

end;

procedure Vichet(var a: matr);

begin

for i:=1 to 5 do

if i mod 2=0 then

for j:=1 to 5 do

a[i,j]:=a[i,j]-a[i-1,j];

end;

begin

randomize;

for i:=1 to 5 do

for j:=1 to 5 do

b[i,j]:= random(10)-5;

writeln(element(A), '-rezultat funkcy');

for i:=1 to 5 do

begin

for j:=1 to 5 do

write(b[i,j]:5);

writeln

end;

vichet(b);

writeln('New');

for i:=1 to 5 do

begin

for j:=1 to 5 do

write(b[i,j]:5);

writeln

end;

end.

Link to comment
Share on other sites

nolx:

nolx:

А потом еще что-нибудь вспомнится?

А ведь прав я был :flowers1:
нужно решить по этой программе
Тогда и получится то, что получится по этой программе. А если менять программу, то у меня получится моя программа :blush2: Edited by Тролль
Link to comment
Share on other sites

  • 6 months later...

@Максимка, просто пиши задания которые тебе задали в теме Заказы "Сделайте все за меня" - СофтФорум для этого она и создана.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...