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
| Program etiquettes_chaines;
uses WinCrt;
const
n=5;
LABEL menu;
var
a:array[1..n] of string[8];
inv,ch:string[8];
choix,i,lg,rest:integer;
rep:boolean;
begin
writeln('.........MENU........');
writeln('1:sasir un vecteur de 5 chaînes de caractères');
writeln('2:inverser ce vecteur');
writeln('3:afficher toutes les chaînes de taille impairs');
writeln('4:afficher les chaînes commençant par ba');
writeln('Faites votre choix');
readln(choix);
rep:=false;
if rep=true then
begin
writeln('entrez les chaînes de caractères');
for i:=1 to n do
begin
readln(ch);
a[i]:=ch;
end;
end;
case choix of
1: begin
rep:=true;
Readkey;
clrscr;
goto menu;
end;
2: begin
rep:=true;
writeln('Inversement du vecteur');
inv:='';
i:=n;
while i>=1 do
begin
inv:=inv+a[i];
i:=i-1;
end;
for i:=1 to n do
writeln(inv);
Readkey;
clrscr;
goto menu;
end;
3: begin
rep:=true;
writeln('Afficher toutes les chaînes de taille impairs');
for i:=1 to n do
begin
lg:=length (ch[i]);
if lg mod 2 <>0 then
writeln(ch[i]);
end;
Readkey;
clrscr;
goto menu;
end;
4: begin
rep:=true;
writeln('afficher les chaînes commençant par ba');
for i:=1 to n do
begin
ch:=a[i];
if (ch[1]='b') or (ch[1]='B') or (ch[2]='a') or (ch[2]='A') then
writeln('la chaîne',i,'commençant par ab est:',ch);
end;
Readkey;
clrscr;
end;
end. |
Partager