Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program лаба4;
- {$APPTYPE CONSOLE}
- uses
- System.SysUtils;
- var
- Continuation: string;
- I: Integer;
- Coordinates, AmountOfPlacesOfProduction, AmountOfSignes: Integer;
- AverageDistanceTemp, AverageDistance: Real;
- function GetAmountOfSignes(Arg: Real): Integer;
- var
- AmountOfSignes, BorderOfAccuracy: Integer ;
- begin
- AmountOfSignes := 0;
- while (Trunc(Arg)<>0) do
- begin
- Arg := Arg / 10;
- Inc(AmountOfSignes);
- end;
- GetAmountOfSignes := AmountOfSignes;
- end;
- begin
- repeat
- try
- WriteLn('Enter coordinates of place of mining.');
- ReadLn(Coordinates);
- WriteLn('Enter amount of places of production.');
- ReadLn(AmountOfPlacesOfProduction);
- AverageDistanceTemp := 0;
- if AmountOfPlacesOfProduction <= 0 then
- WriteLn('Amount must be positiv.')
- else
- begin
- for I := 1 to AmountOfPlacesOfProduction do
- begin
- AverageDistanceTemp := sqrt (2)* abs(Coordinates - I);
- AmountOfSignes := GetAmountOfSignes(AverageDistanceTemp);
- Writeln ('Distance to ',I,' place of production = ',
- AverageDistanceTemp:AmountOfSignes+2:3);
- AverageDistance := AverageDistance + AverageDistanceTemp;
- end;
- AverageDistance := AverageDistance / AmountOfPlacesOfProduction;
- AmountOfSignes := GetAmountOfSignes(AverageDistance);
- WriteLn('Average distance = ',AverageDistance:AmountOfSignes+2:3);
- repeat
- WriteLn('Stop?Y/N');
- ReadLn(Continuation);
- Continuation := UpperCase(Continuation);
- until (Continuation = 'Y') or (Continuation = 'N');
- end;
- except
- on EInOutError do
- WriteLn('Amount of places of production must be positiv ',
- 'and integer.Coordinates must be integer.');
- end;
- until Continuation = 'Y';
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement