Cod sursa(job #405805)

Utilizator gabyca93Kuzman Gabriella gabyca93 Data 28 februarie 2010 19:35:39
Problema Text Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 2.16 kb
uses crt;
type szemely=record
                   nev:string;
                   magas:0..250;
             end;
var n,v,i,m,j:integer;
    k:szemely;
    sz:byte;
    t:array[1..100] of szemely;
    nv:string;
    h,l,hal:set of char;
    nev,knev:string;
    c:char;

begin
repeat
writeln;
writeln('1. beolvas');
writeln('2.kiir');
writeln('3.* hozzafuzese');
writeln('4.Panni');
writeln('5.Kozos karakterek');
writeln('6.kilepes');
writeln('Valasztasod?');readln(v);
case v of
1: begin
i:=0;
repeat
   writeln('nev:');readln(nv);
   writeln('magassag:');readln(m);
   if nv<>'*' then begin
   i:=i+1;
   t[i].nev:=nv;
   t[i].magas:=m;
   end;
until nv='*';
n:=i;
   end;
2:begin
       for i:=1 to n-1 do
           for j:=i+1 to n do
               if t[i].magas<t[j].magas then begin
                                             k:=t[i];
                                             t[i]:=t[j];
                                             t[j]:=k;
                                             end;

       for i:=1 to n do
       writeln(t[i].nev,'   ',t[i].magas);
  end;
3:for i:=1 to n do
      t[i].nev:='*'+t[i].nev+'*';
4:for i:=1 to n do
           if length(t[i].nev)>8 then begin
                                           sz:=pos(' ',t[i].nev);
                                           delete(t[i].nev,sz,length(t[i].nev)-sz+1);
                                           t[i].nev:=t[i].nev+' Panni';
                                      end;
5: begin
        for i:=1 to n do
        begin
             sz:=pos(' ',t[i].nev);
             nev:=copy(t[i].nev,1,sz-1);
             knev:=copy(t[i].nev,sz+1,length(t[i].nev)-sz);
             h:=[];
             for sz:=1 to length(nev) do
              if not(nev[sz] in h) then
                 h:=h+[nev[sz]];
              l:=[];
             for sz:=1 to length(knev) do
              if not(knev[sz] in l) then
                 l:=l+[knev[sz]];
             hal:=h*l;
             write(t[i].nev,'    ');
             for c:='A' to 'z' do
                 if (c in hal) then write(c,' ');
             writeln;
        end;
   end;
end;
until v=6;
end.