tags:

views:

46

answers:

1

Hi, I have this task and i can't figure out how to do it. I need to find persons age in days, there are given birth and death dates, there's data file:

8   
Albertas Einšteinas     1879 03 14 1955 04 18         
Balys Sruoga            1896 02 02 1947 10 16  
Antanas Vienuolis       1882 04 07 1957 08 17   
Ernestas Rezerfordas    1871 08 30 1937 10 17   
Nilsas Boras            1885 10 07 1962 11 18   
Nežiniukas Pirmasis        8 05 24    8 05 25  
Nežiniukas Antrasis      888 05 25  888 05 25   
Nežiniukas Trečiasis       1 01 01  125 01 01

and there's how result file should look like:

1879 3 14 1955 4 18 27775
1896 2 2 1947 10 16 18871
1882 4 7 1957 8 17 27507
1871 8 30 1937 10 17 24138
1885 10 7 1962 11 18 28147
8 5 24 8 5 25 1
888 5 25 888 5 25 0
1 1 1 125 1 1 45260

Few things to notice: all februarys have 28 days. My function for calculating age:

  function AmziusFunc(Mas : TZmogus) : longint;
    var amzius, max : longint;
  begin
    max := 125 * 365;
    amzius := (Mas.mirY - Mas.gimY) * 365 + (Mas.mirM - Mas.gimM) * 31 +
      (Mas.mirD - Mas.gimD);
    if ( amzius >= max ) then amzius := 0;
    AmziusFunc := amzius;
  end;

What should i change there? Thanks.

A: 

function AmziusFunc(Mas : TZmogus) : longint; var amzius, max : longint; begin max := 125 * 365; amzius := (Mas.mirY - Mas.gimY) * 365 + (Mas.mirM - Mas.gimM) * 31 + (Mas.mirD - Mas.gimD); if ( amzius >= max ) then amzius := 0; AmziusFunc := amzius; end;

bah