Advertisement
KrestininVladislav

Untitled

Sep 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. program лаба4;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. System.SysUtils;
  7.  
  8. var
  9. Continuation: string;
  10. I: Integer;
  11. Coordinates, AmountOfPlacesOfProduction, AmountOfSignes: Integer;
  12. AverageDistanceTemp, AverageDistance: Real;
  13.  
  14. function GetAmountOfSignes(Arg: Real): Integer;
  15.  
  16. var
  17. AmountOfSignes, BorderOfAccuracy: Integer ;
  18.  
  19. begin
  20. AmountOfSignes := 0;
  21. while (Trunc(Arg)<>0) do
  22. begin
  23. Arg := Arg / 10;
  24. Inc(AmountOfSignes);
  25. end;
  26. GetAmountOfSignes := AmountOfSignes;
  27. end;
  28.  
  29. begin
  30. repeat
  31. try
  32. WriteLn('Enter coordinates of place of mining.');
  33. ReadLn(Coordinates);
  34. WriteLn('Enter amount of places of production.');
  35. ReadLn(AmountOfPlacesOfProduction);
  36. AverageDistanceTemp := 0;
  37. if AmountOfPlacesOfProduction <= 0 then
  38. WriteLn('Amount must be positiv.')
  39. else
  40. begin
  41. for I := 1 to AmountOfPlacesOfProduction do
  42. begin
  43. AverageDistanceTemp := sqrt (2)* abs(Coordinates - I);
  44. AmountOfSignes := GetAmountOfSignes(AverageDistanceTemp);
  45. Writeln ('Distance to ',I,' place of production = ',
  46. AverageDistanceTemp:AmountOfSignes+2:3);
  47. AverageDistance := AverageDistance + AverageDistanceTemp;
  48. end;
  49. AverageDistance := AverageDistance / AmountOfPlacesOfProduction;
  50. AmountOfSignes := GetAmountOfSignes(AverageDistance);
  51. WriteLn('Average distance = ',AverageDistance:AmountOfSignes+2:3);
  52. repeat
  53. WriteLn('Stop?Y/N');
  54. ReadLn(Continuation);
  55. Continuation := UpperCase(Continuation);
  56. until (Continuation = 'Y') or (Continuation = 'N');
  57. end;
  58. except
  59. on EInOutError do
  60. WriteLn('Amount of places of production must be positiv ',
  61. 'and integer.Coordinates must be integer.');
  62. end;
  63. until Continuation = 'Y';
  64. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement