1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
Program Calcul;
uses math, unite,sysutils ;
Procedure Saisie (var coord1, coord2 : Coordonnees);
var
entree, sortie1,sortie2 : text;
strlatitude, strlongitude, strville: String;
var
pa,pd : string;
Var Found : Boolean;
begin
Found := False;
begin
writeln ('Point de depart');
readln(pd);
writeln ('Point arrivee');
readln(pa);
assign(entree,'destination.txt');
reset(entree);
while not(eof(entree)) or (not(Found)) do
readln(entree, strlatitude);
readln(entree, strlongitude);
readln(entree, strville);
// begin
if strville = pa then // Test ville de depart
begin
Found := True;
assign(sortie1,'depart.txt');
rewrite(sortie1);
writeln (sortie1, strlatitude);
writeln (sortie1, strlongitude);
close(sortie1);
end;
if not(Found) then
begin
Writeln('Ville non trouvée.');
Exit;
end;
if strville = pd then // Test ville d'arrivé
begin
assign (sortie2, 'arrivee.txt');
rewrite(sortie2); // on ouvre le fichier en ecriture
writeln(sortie2, strlatitude); // on ecrit dans le fichier
writeln (sortie2, strlongitude); // on ecrit dans le fichier
close(sortie2);
end;
if not(Found) then
begin
Writeln('Ville non trouvée.');
Exit;
end;
end; // Fin du while
////////////////////////////////
close (entree);
// On Verifie ce qui a ete ecrit et on le passe en paramettre
assign(sortie1,'depart.txt');
reset(sortie1);
readln(sortie1,StrLongitude);
writeln (StrLongitude); // Les coordonees en texte ?
readln(sortie1,Strlatitude);
writeln (Strlatitude);
coord1.longitude := StrToFloat(StrLongitude);
coord1.latitude:= StrToFloat(Strlatitude);
close(sortie1);
assign(sortie2,'arrivee.txt');
reset(sortie2);
readln(sortie2,StrLongitude); // Les coordonees en texte ?
writeln (StrLongitude);
readln (sortie2,Strlatitude);
writeln (Strlatitude);
coord2.longitude := StrToFloat(StrLongitude);
coord2.latitude:= StrToFloat(Strlatitude);
close (sortie2);
end;
Function Calculcurviligne (coord1,coord2: Coordonnees) : Real;
var S, delta, distance: Real;
Begin
delta := (Coord2.Longitude-Coord1.Longitude);
S := arccos (sin(Coord1.latitude)*sin(Coord2.latitude) + cos(Coord1.latitude)*cos(Coord2.latitude)*cos(delta) );
distance := 6378*S;
Calculcurviligne := distance;
end;
Procedure Affichage (coord1, coord2 : Coordonnees; var distance : Real);
Begin
distance:=Calculcurviligne(coord1,coord2);
writeln ('Distance a parcourir ', distance);
end;
var distance : Real;
var coord1, coord2 : Coordonnees;
begin
Saisie (coord1, coord2);
Affichage(coord1, coord2, distance);
end. |
Partager