program ex1; {$APPTYPE CONSOLE} uses
SysUtils; Const
n=5; Type
vettore=Array[1..n]ofchar; Var
V:vettore;
i:Integer;
s:String; Function Test_STR(V:Vettore;S:String):Boolean; Function Test_CHR(V:Vettore;C:Char):Boolean; var
i:Integer;
trovato_CHR:boolean; Begin
i:=1;
trovato_chr:=false; While(i<=n)and(trovato_chr=false)and(V[i]<=C)do begin
trovato_chr:=(V[i]=c);
inc(i); end;
Test_CHR:=trovato_chr; End; var
i:integer;
trovato:Boolean; begin
i:=1;
trovato:=true; While(i<=Length(s))and(trovato=true)do begin
trovato:=Test_CHR(v,S[i]);
inc(i); end;
Test_STR:=Trovato; End; //l'array viene fornito già ordinato. begin Writeln('inserisci gli elementi del vettore (ordinati!!!)'); For i:=1to n do Readln(V[i]); Writeln('Inserisci la stringa da cercare'); Readln(s); Writeln('Risultato test di esistenza:'); writeln(Test_STR(V,s)); readln; end.