Advertisement
KrestininVladislav

Untitled

Sep 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 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(X : Real): Integer;
  15.  
  16. var
  17. AmountOfSignes, BorderOfAccuracy: Integer ;
  18.  
  19. begin
  20. AmountOfSignes:=0;
  21. BorderOfAccuracy:=0;
  22. while (Frac(X)<>0) and (BorderOfAccuracy < 12) do
  23. begin
  24. X:=X*10;
  25. Inc(AmountOfSignes, BorderOfAccuracy);
  26. end;
  27. GetAmountOfSignes := AmountOfSignes;
  28. end;
  29.  
  30. begin
  31. repeat
  32. try
  33. WriteLn('Enter coordinates of place of mining.');
  34. ReadLn(Coordinates);
  35. WriteLn('Enter amount of places of production.');
  36. ReadLn(AmountOfPlacesOfProduction);
  37. AverageDistanceTemp := 0;
  38. if AmountOfPlacesOfProduction <= 0 then
  39. WriteLn('Amount must be positiv.')
  40. else
  41. begin
  42. for I := 1 to AmountOfPlacesOfProduction do
  43. begin
  44. AverageDistanceTemp := sqrt (2*sqr(Coordinates - I));
  45. AmountOfSignes := GetAmountOfSignes(AverageDistanceTemp);
  46. Writeln ('Distance to ',I,' place of production =',
  47. AverageDistanceTemp:AmountOfSignes:AmountOfSignes);
  48. AverageDistance := AverageDistance + AverageDistanceTemp;
  49. end;
  50. AverageDistance := AverageDistance / AmountOfPlacesOfProduction;
  51. AmountOfSignes := GetAmountOfSignes(AverageDistance);
  52. WriteLn('Average distance = ',AverageDistance:AmountOfSignes:AmountOfSignes);
  53. repeat
  54. WriteLn('Stop?Y/N');
  55. ReadLn(Continuation);
  56. Continuation := UpperCase(Continuation);
  57. until (Continuation='Y') or (Continuation='N');
  58. end;
  59. except
  60. on EInOutError do
  61. Write('Amount of places of production must be positiv and integer.',
  62. 'Coordinates must be integer ');
  63. end;
  64. until Continuation='Y';
  65. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement