D
D
d4Rk_ag3Nt2016-01-25 23:38:52
Pascal
d4Rk_ag3Nt, 2016-01-25 23:38:52

Who will help to arrange comments to the pascal code?

The first control, I don’t really understand yet, the programs are also the first. I wrote the programs, they seem to work, they are not able to explain)) Help with comments on the following codes:
1.

uses strutils;
var
  s, w, last : string;
  i, j, wc : integer;
  b : boolean;
begin
  s := 'nokia samsung sony siemens apple dns nokia dns.';
  wc := wordcount(s, [' ', '.']);
  last := extractdelimited(wc, s, [' ', '.']);
  writeln(wc);
  for i := 1 to wc - 1 do
  begin
    w := extractdelimited(i, s, [' ', '.']);
    if w <> last then
    begin
      b := true;
      for j := length(w) downto 1 do
        b := b and (pos(copy(w, j, 1), w) = j);
      if b then writeln(w);
    end;
  end;
end.

2.
Const
  nn=50;
type
  data = record
    number : 1..31;
    month : 1..12;
    year : 1901..1997
  end;
var
  d:array[1..nn] of data;
  i,n,k:integer;
  s,s1,s2,s3:string;
begin
  Write('Количество дат (1..50)-> '); Read(n);
  Writeln('Введите через пробел день, месяц, год: ');
  for i:=1 to n do Read(d[i].number,d[i].month,d[i].year);
  { a }
  Write('Самый ранний из годов: ');
  k:=d[1].year;
  for i:=2 to n do
    if d[i].year<k then k:=d[i].year;
  Writeln(k);
  { б }
  Writeln('Все весенние даты');
  for i:=1 to n do
    if d[i].month in [3..5] then
      Write(d[i].number,'.',d[i].month,'.',d[i].year,' ');
  Writeln;
  { в }
  Write('Cамая поздняя дата: ');
  Str(d[1].year,s1); Str(d[1].month,s2); Str(d[1].number,s3);
  if Length(s2)=1 then s2:='0'+s2;
  if Length(s3)=1 then s3:='0'+s3;
  s:=s1+s2+s3;
  for i:=2 to n do
  begin
    Str(d[i].year,s1); Str(d[i].month,s2); Str(d[i].number,s3);
    if Length(s2)=1 then s2:='0'+s2;
    if Length(s3)=1 then s3:='0'+s3;
    if s<s1+s2+s3 then s:=s1+s2+s3
  end;
  Writeln(Copy(s,7,2)+'.'+Copy(s,5,2)+'.'+Copy(s,1,4))
end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2016-01-25
@dimonchik2013

freelansim.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question