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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
program fichier ;
uses wincrt;
type chaine =record
ph :string;
ta :integer;
end;
var f: file of chaine;
c:chaine;
paly:boolean;
ta,n, i, tamax,phrase:integer;
phrasemax:string;
procedure creation(n:integer);
begin
tamax:=0;
assign(f,'nom');
rewrite(f);
for i:= 1 to n do
begin
writeln('inserer la phrase');
readln(c.ph);
c.ta:= length(c.ph);
write(f,c);
end;
end;
procedure plus_longue;
begin
reset(f);
while not eof (f) do
begin
read(f,c);
if c.ta>tamax then
begin
tamax:= c.ta;
phrasemax:= c.ph;
end;
end;
write ('la phrase la plus longue est',phrasemax);
end;
procedure palyndrome( paly:boolean);
begin
reset(f);
readln(c.ph);
readln(c.ta);
paly := true;
i:=1;
while i<=ta div 2 do
begin
if paly= true then
if c.ph[i]=c.ph[ta-i+1] then
i:=i+1;
end;
procedure tri(t:tab);
var t:array[1..20] of c;
nb :integer;
begin
nb:=1;
reset(f);
while not eof(f) do
t[nb]:=(f,c);
nb :=nb +1;
end;
for i:= 1 to nb-1 do
for j:= i+1 to nb do
begin
if t[i].ta <t[j].ta then
begin
ta :=t[i];
t[i]:=t[j];
t[j]:=ta;
end;
procedure affichage ;
begin
assign(f);
reset(f);
while not eof(f) do
begin
read (f,ta);
write(c.phrase);
write(c.ta);
end;
close(f);
end;
BEGIN
ch:=0;
while ch<>8 do
begin
clrscr;
for i:=1 to 30 do begin gotoxy(i,1);write('*');end;
for i:=1 to 18 do begin gotoxy(1,i);write('*');gotoxy(30,i);write('*');end;
for i:=1 to 30 do begin gotoxy(i,18);write('*');end;
gotoxy(12,3);writeln('MENU:');
gotoxy(5,5);writeln('1/ creation de fichier');
gotoxy(5,6);writeln('2/ la phrase la plus long');
gotoxy(5,7);writeln('3/ le nombre de mots palyndrome');
gotoxy(5,8);writeln('4/ tri de fichier par taille');
gotoxy(5,9);writeln('5/ affichage');
gotoxy(5,10);writeln('6/ quitter');
writeln;
gotoxy(10,15);write('CHOIX : ');
readln(ch);
writeln;
gotoxy(1,20);
case ch of
1:creation(n);
2:plus _long;
3:palyndrome(paly);
4:tri(t);
5:affichage;
6:quitter;
end;
writeln;
end;
readln;
END. |
Partager