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
| program textToTab;
uses crt;
type CARTE = array[1..10] of string[40];
R_CARTE = record nom: string[40];
numero : integer;
tCarte : array[65..75] of CARTE;
end;
T_R_CARTE = array[1..1000] of R_CARTE;
var s : string;
n1, n2, i, j, ordc1, ordc2 : integer;
c1, c2 : char;
ftext : text;
tableauDeGrilles: T_R_CARTE;
begin
assign(ftext,'C:\Users\Utilisateur\Documents\Université\Cours Programmation\Projet\carto.txt');
reset(ftext);
i:=1;
while not eof(ftext) do
begin
s:='';
while (s <>'Carte Indien') AND (s <>'Carte Pacifique') AND (s <>'Carte Atlantique') do
begin
read(ftext, c1);
s:=s+c1;
end;
tableauDeGrilles[i].nom:=s;
readln(ftext, n1);
tableauDeGrilles[i].numero:=n1;
s:='';
j:=0;
while (j<5) do
begin
read(ftext, c1);
while (c1 <> ' ') do
begin
s:=s+c1;
read(ftext, c1);
end;
read(ftext, c1);
read(ftext, n1);
ordc1:=ord(c1);
tableauDeGrilles[i].tCarte[ordc1][n1]:=s;
read(ftext, c2);
read(ftext, c2); {on met dans la grille les 2 coordonées du bateau
données dans le fichier text}
readln(ftext, n2);
ordc2:=ord(c2);
tableauDeGrilles[i].tCarte[ordc2][n2]:=s;
if (ordc1 > ordc2) then
begin
ordc2:=ordc2+1;
while(ordc1 <> ordc2) do
begin
tableauDeGrilles[i].tCarte[ordc2][n2]:=s;
ordc2:=ordc2+1;
end;
end
else if (ordc1 < ordc2) then
begin
ordc1:=ordc1+1;
while (ordc1 <> ordc2) do
begin
tableauDeGrilles[i].tCarte[ordc1][n1]:=s;
ordc1:=ordc1+1;
end;
end
else if ((ordc1 = ordc2) AND (n1 > n2)) then
begin
n2:=n2+1;
while(n1 <> n2) do
begin
tableauDeGrilles[i].tCarte[ordc2][n2]:=s;
n2:=n2+1;
end;
end
else if ((ordc1 = ordc2) AND (n1 < n2)) then
begin
n1:=n1+1;
while (n1 <> n2) do
begin
tableauDeGrilles[i].tCarte[ordc2][n1]:=s;
n1:=n1+1;
end;
end;
j:=j+1;
s:='';
end;
i:=i+1;
end;
writeln(tableauDeGrilles[1].tCarte[66][2]);
writeln(tableauDeGrilles[5].nom, tableauDeGrilles[2].numero);
readln;
close(ftext);
end. |
Partager