const N = 10; a: array[1..N] of integer = (34, 16, 28, 12, 5, 4, 11, 16, 2, 8 ); function Lze( soucet: integer; od: integer ): boolean; begin if soucet=0 then Lze := TRUE else if od > N then Lze := FALSE else if Lze( soucet, od+1 ) then Lze := TRUE else if Lze( soucet-a[od], od+1 ) then begin write( a[od],' ' ); Lze := TRUE end else Lze := FALSE end; begin writeln( Lze( 68, 1 ) ); readln end. procedure VypisVsechnyPermutace( zceho, coVytisknoutPredKazdou: string ); var i: integer; begin if zceho='' then writeln( coVytisknoutPredKazdou ) else for i:= 1 to length( zceho ) do VypisVsechnyPermutace( copy( zceho, 1, i-1 ) + copy( zceho, i+1, 255 ), coVytisknoutPredKazdou + zceho[i] ) end; begin VypisVsechnyPermutace( 'abcd', '' ); readln; VypisVsechnyPermutace( '123456789', '' ); readln end. procedure Presun( odkud, kam, N: integer ); begin if N=1 then writeln( odkud, '-->', kam ) else begin Presun( odkud, 6-odkud-kam, N-1 ); Presun( odkud, kam, 1 ); Presun( 6-odkud-kam, kam, N-1 ) end; end; begin Presun( 1, 2, 1 ); writeln( '-----------------------' ); Presun( 1, 2, 2 ); writeln( '-----------------------' ); Presun( 1, 2, 3 ); writeln( '-----------------------' ); readln end. {$O+} var Vysledek: array[0..10000] of integer; UzZnam: array[0..10000] of boolean; function fib( i: integer ): integer; begin if UzZnam[i] then fib := Vysledek[i] else begin if i<=1 then Vysledek[i] := 1 else Vysledek[i] := fib( i-1 ) + fib( i-2 ); fib := Vysledek[i]; UzZnam[i] := TRUE end end; var i: integer; begin for i:=1 to 10000 do writeln( i:3, ' ', fib(i) ) end. {$O+} function fib( i: integer ): integer; begin if i<=1 then fib := 1 else fib := fib( i-1 ) + fib( i-2 ) end; var i: integer; begin for i:=1 to 50 do writeln( i:3, ' ', fib(i) ) end. function ZjistiHodnotu( s: string ): integer; const NENASELjsemNIC = -1; JEtoCELEvZAVORKACH = -2; function NajdiOperatorSNejmensiPrioritou: integer; var imin, min, i, priorita, ZAVORKY: integer; begin min := MAXINT; imin := NENASELjsemNIC; ZAVORKY := 0; for i:=1 to length(s) do if (s[i]='+') or (s[i]='-') then begin priorita := 1 + ZAVORKY; if priorita <= min then begin min := priorita; imin := i end; end else if (s[i]='*') or (s[i]='/') then begin priorita := 2 + ZAVORKY; if priorita <= min then begin min := priorita; imin := i end; end else if (s[i]='(') then ZAVORKY := ZAVORKY + 10 else if (s[i]=')') then ZAVORKY := ZAVORKY - 10; NajdiOperatorSNejmensiPrioritou := imin; if (imin>0) and (min > 10) then NajdiOperatorSNejmensiPrioritou := JEtoCELEvZAVORKACH end; function HodnotaCisla( s: string ): integer; var i, x: integer; begin x := 0; for i:=1 to length( s ) do x := 10*x + ord(s[i]) - ord('0'); HodnotaCisla := x end; var KdeJeOperator: integer; begin writeln( ':',s ); KdeJeOperator := NajdiOperatorSNejmensiPrioritou; if KdeJeOperator = NENASELjsemNIC then ZjistiHodnotu := HodnotaCisla( s ) else if KdeJeOperator = JEtoCELEvZAVORKACH then ZjistiHodnotu := ZjistiHodnotu( copy(s, 2, length(s)-2) ) else begin if s[ KdeJeOperator ] = '+' then ZjistiHodnotu := ZjistiHodnotu( copy(s,1,KdeJeOperator-1) ) + ZjistiHodnotu( copy(s,KdeJeOperator+1,255) ) else if s[ KdeJeOperator ] = '-' then ZjistiHodnotu := ZjistiHodnotu( copy(s,1,KdeJeOperator-1) ) - ZjistiHodnotu( copy(s,KdeJeOperator+1,255) ) else if s[ KdeJeOperator ] = '*' then ZjistiHodnotu := ZjistiHodnotu( copy(s,1,KdeJeOperator-1) ) * ZjistiHodnotu( copy(s,KdeJeOperator+1,255) ) else if s[ KdeJeOperator ] = '/' then ZjistiHodnotu := ZjistiHodnotu( copy(s,1,KdeJeOperator-1) ) div ZjistiHodnotu( copy(s,KdeJeOperator+1,255) ) end; end; begin writeln( ZjistiHodnotu( '5+3' ) ); writeln( ZjistiHodnotu( '6+29' ) ); writeln( ZjistiHodnotu( '(7*5+2)-8*(29-10)' ) ); readln end. {===========================================================} const MAX = 100; var slova: array[1..MAX] of string; pocty: array[1..MAX] of integer; N: integer; procedure Nacti; var f: text; procedure OtevriSoubor; begin { assign( f, 'p181029.pas' ); } assign( f, 'c:\Windows\DirectX.log' ); reset( f ) end; function JePismeno( znak: char ): boolean; begin JePismeno := ((znak>='a') and (znak<='z')) or ((znak>='A') and (znak<='Z')) or (znak='(') or (znak=')') end; function NactiSlovo: string; var slovo: string; znak: char; begin read( f, znak ); while (not eof(f)) and (not JePismeno( znak )) do read( f, znak ); slovo := ''; while (not eof(f)) and (JePismeno( znak )) do begin slovo := slovo + znak; read( f, znak ) end; if JePismeno(znak) then slovo := slovo + znak; NactiSlovo := slovo end; procedure PridejDoSeznamu( slovo: string ); var i: integer; begin slova[ N+1 ] := slovo; pocty[ N+1 ] := 1; for i:=1 to N do if slova[i] = slovo then begin pocty[ i ] := pocty[ i ] +1; exit; end; N := N+1 end; var slovo: string; i: integer; begin N := 0; OtevriSoubor; slovo := NactiSlovo; while slovo<>'' do begin { ... } { writeln( '>',slovo,'<' ); } PridejDoSeznamu( slovo ); slovo := NactiSlovo end; for i:=1 to N do writeln( pocty[i],'x ', slova[i] ); readln end; procedure NajdiVytiskniAZahodNejcastejsiSlovo; var imax, i: integer; begin imax := 1; for i:=2 to N do if pocty[i] > pocty[imax] then imax := i; writeln( pocty[imax]:3,'.....',slova[imax] ); slova[ imax ] := slova[ N ]; pocty[ imax ] := pocty[ N ]; N := N-1 end; var i: integer; begin Nacti; {Vytiskni} for i:=1 to 20 do NajdiVytiskniAZahodNejcastejsiSlovo; readln end. var A: array[1..1000] of integer; var B: array[1..1000] of integer; type POLE = array[1..1000] of integer; var X: POLE; Y: POLE; var M: array[1..10] of array [1..20] of boolean; begin X := Y; M[1] := M[7]; end. function Minimum( X: POLE ): integer; begin Minimum := 5 end; begin writeln( Minimum( Y ) ) end. function Sedm( a: integer ): integer; begin end; function Osm : integer; var k: integer; begin Osm := k end; begin writeln( Osm ); writeln( Sedm(1) ) end. program Project1; procedure VytiskniRadkuX; begin { writeln( i ); } writeln( 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' ) end; procedure VytiskniNadpis; var i: integer; begin write( 'X X' ); for i:=1 to 10 do write( i:4 ); writeln( ' X' ) end; var i: integer; procedure VytiskniNasobkyCisla( ceho: integer ); var i: integer; begin write( 'X ',ceho:2,' X' ); for i:=1 to 10 do write( i*ceho:4 ); writeln( ' X' ) end; begin VytiskniRadkuX(); VytiskniNadpis(); VytiskniRadkuX(); for i:=1 to 20 do VytiskniNasobkyCisla( i ); VytiskniRadkuX() ; readln() end.