Advertisement
KirillMysnik

Вторая лаба

Sep 12th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.78 KB | None | 0 0
  1. program lab2; const nmax = 255; var i, n, counter : Byte; p : Real; a : array[1..nmax] of Real; b : array[1..nmax] of Real; c : array[1..nmax] of Real; begin write('Enter number of triples: '); readln(n); if n = 0 then writeln('Cannot input 0 triples! ') else begin for i := 1 to n do begin writeln('i = ', i); write('Ai: '); readln(a[i]); write('Bi: '); readln(b[i]); write('Ci: '); readln(c[i]); end; counter := 0; p := 0; for i := 1 to n do if (a[i] + b[i] > c[i]) and (b[i] + c[i] > a[i]) and (c[i] + a[i] > b[i]) then begin writeln('i = ', i, ': Ai..Bi..Ci is a possible triangle!'); counter := counter + 1; p := p + a[i] + b[i] + c[i]; end; writeln('Number of possible triangles: ', counter:3); writeln('Total perimeter: ', p:5:1); writeln('Press [Enter] to quit...'); readln; end; end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement