program fejvagyiras; const m=1000; var egymasutan,dobas,dobas2,sum,j,fej,iras, maxindex,max,db,ffff,fffi, i,n:integer; T:array [1..5000] of char; a:array [1..4*m] of char; tipp,egydobas,dobott:string[2]; relativ: real; f:text; begin randomize; writeln('1. feladat'); dobas:=random(2)+1; if dobas=1 then begin egydobas:='I'; writeln(egydobas) end else if dobas=2 then begin egydobas:='F'; writeln(egydobas); end; writeln('2. feladat'); writeln('irja be tippjet: '); readln(tipp); dobott:=egydobas; writeln('a Tipp: ',tipp,' a dobas: ',dobott); if tipp=dobott then writeln('eltalalta') else writeln('nem talalta'); writeln('3. feladat'); Assign(f,'kiserlet.txt'); reset(f); i:=0; while not eof(f) do begin inc(i); readln(f,T[i]); end; n:=i; writeln(n,' dobas tortent'); writeln('4. feladat'); for i:=1 to n do if T[i]='F' then inc(fej); relativ:=(fej/n)*100; writeln('fej relativ gyakorisaga: ',relativ:2:2,'%'); writeln('5. feladat'); i:=1; if ((T[i]='F') and (T[i+1]='F') and (T[i+2]='I')) then inc(egymasutan); for i:=1 to n-3 do if ((T[i]='I') and (T[i+1]='F') and (T[i+2]='F') and (T[i+3]='I')) then inc(egymasutan); i:=n-2; if ((T[i]='I') and (T[i+1]='F') and (T[i+2]='F')) then inc(egymasutan); writeln('2 fej ennyiszer talalhato egymas utan: ',egymasutan); writeln('6. feladat'); max:=0; maxindex:=0; //n:=50; for i:=1 to n-1 do begin if T[i] = 'F' then begin db:=1; j:=i+1; while (j<=n) and (T[j]='F') do begin inc(db); inc(j); end; if db>max then begin max:=db; maxindex:=i; end; end; end; writeln('a leghosszabb tisztafej ',max,' elemu, ',maxindex,' -tol'); writeln('7. feladat'); for i:=1 to 4*m do begin if random > 0.5 then a[i]:='F' else a[i]:='I'; write(a[i]); if i mod 4 = 0 then write(' '); end; //4*i+1 i=0..m-1 for i:=0 to m-1 do begin j:=4*i+1; if ((a[j]='F') and (a[j+1]='F') and (a[j+2]='F') and (a[j+3]='F')) then inc(ffff); if ((a[j]='F') and (a[j+1]='F') and (a[j+2]='F') and (a[j+3]='I')) then inc(fffi); end; writeln; writeln('FFFF:',ffff,', FFFI:',fffi); readln; end.