Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
- ExtCtrls;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- Button7: TButton;
- Button8: TButton;
- Button9: TButton;
- Edit1: TEdit;
- Edit2: TEdit;
- Image1: TImage;
- Timer1: TTimer;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure Button6Click(Sender: TObject);
- procedure Button7Click(Sender: TObject);
- procedure Button8Click(Sender: TObject);
- procedure Button9Click(Sender: TObject);
- procedure Edit1Change(Sender: TObject);
- procedure Edit2Change(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- a1,a3:string;
- i,a,xx,yy,xxx,yyy:integer;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- image1.canvas.fillrect(image1.clientrect);
- a:=0;
- a3:=edit1.text;
- a1:=edit1.text;
- for i:=1 to length(edit1.text) do
- a3[i]:='?';
- image1.canvas.textout(25,25,a3);
- xx:=10;
- yy:=10;
- end;
- procedure TForm1.Timer1Timer(Sender: TObject);
- var slovo:string;
- begin
- image1.canvas.fillrect(image1.clientrect);
- slovo:=edit1.text;
- if (xx<image1.width) and (yy<image1.Height) then
- begin
- image1.canvas.textout(xx,yy,slovo);
- xx:=xx+25;
- yy:=yy+25;
- xxx:=xx;
- yyy:=yy;
- end
- else
- begin
- for i:=1 to length(slovo) do
- begin
- image1.canvas.textout(xxx,yyy,slovo[i]);
- randomize;
- image1.canvas.Font.color:=random(256*256*256);
- xxx:=xxx-random(25);
- yyy:=yyy-random(25);
- end;
- end;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- var a:char;
- i,x,y:integer;
- begin
- x:=15;
- y:=15;
- for i:=1 to 256 do
- begin
- a:=char(i-1);
- image1.canvas.textout(x,y,a + '=' + inttostr(i-1));
- y:=y+15;
- if y+20>image1.Height then
- begin
- y:=15;
- x:=x+40;
- end;
- end;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var a:string;
- i,slovo,veta,velke,male,cisla:integer;
- begin
- a:=edit1.text;
- slovo:=1;
- veta:=0;
- velke:=0;
- male:=0;
- cisla:=0;
- for i:=1 to length(a) do
- begin
- if a[i]=' ' then
- slovo:=slovo+1;
- if (a[i]='.') or (a[i]='?') or (a[i]='!') then
- veta:=veta+1;
- if (a[i]>='A') and (a[i]<='Z') then
- velke:=velke+1;
- if (a[i]>='a') and (a[i]<='z') then
- male:=male+1;
- if (a[i]>='0') and (a[i]<='9') then
- cisla:=cisla+1;
- end;
- showmessage(format('raťazec: ( %s ) je dlhý %d znakov a obsahuje %d slov, %d viet, %d veľkých pismen, %d malých písmen a %d čísel',[a,length(a),slovo,veta,velke,male,cisla]));
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var a,slovo:string;
- x,y,i:integer;
- begin
- a:=edit1.text;
- y:=25;
- x:=25;
- image1.canvas.textout(x,y,a);
- y:=y+50;
- for i:=1 to length(a) do
- begin
- if a[i]<>' ' then
- slovo:=slovo+a[i]
- else
- begin
- image1.canvas.textout(x,y,slovo);
- slovo:=' ';
- y:=y+25;
- end;
- end;
- image1.canvas.textout(x,y,slovo);
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- var a,slovo,reverse:string;
- x,y,i,j:integer;
- begin
- a:=edit1.text;
- reverse:=' ';
- y:=25;
- x:=25;
- image1.canvas.textout(x,y,'pôvodne slovo je: '+a);
- y:=y+25;
- for i:=1 to length(a) do
- begin
- if (a[i]<>' ') and (a[i]<>'.') and (a[i]<>',') and (a[i]<>'?') and (a[i]<>'!') then
- slovo:=slovo+a[i]
- else
- begin
- for j:=1 to length(slovo) do
- reverse:=reverse+slovo[length(slovo)-j+1];
- reverse:=reverse+a[i];
- slovo:=' ';
- end;
- end;
- for j:=1 to length(slovo) do
- reverse:=reverse+slovo[length(slovo)-j+1];
- image1.canvas.textout(x,y,'obrátené slovo je: '+ reverse);
- end;
- procedure TForm1.Button5Click(Sender: TObject);
- const samohlasky='aeiou';
- var a:string;
- b:char;
- i,j,x,y,zadanie:integer;
- begin
- zadanie:=strtoint(inputbox('vstup','zadaj cast ulohy',''));
- a:=edit1.text;
- x:=25;
- y:=25;
- image1.canvas.textout(x,y,'pôvodna veta je: '+a);
- case zadanie of
- 1:
- begin
- for i:=1 to length(samohlasky) do
- begin
- b:=samohlasky[i];
- for j:= 1 to length(a) do
- begin
- if (a[j]='a') or (a[j]='e') or (a[j]='i') or (a[j]='o') or (a[j]='u') then
- a[j]:=b;
- end;
- y:=y+25;
- image1.canvas.textout(x,y,a);
- end;
- end;
- 2:
- begin
- image1.canvas.fillrect(image1.clientrect);
- {for i:=1 to length(a) do
- begin
- if a[i]=' ' then
- a[i]:='*';
- end;
- y:=y+25;
- image1.canvas.textout(x,y,a);}
- {i:=pos(' ',a);
- while i<>0 do
- begin
- a:=copy(a,1,i-1)+'***'+copy(a,i+1,maxint);
- i:=pos(' ',a);
- end;
- image1.canvas.textout(x,y,a);}
- {i:=pos(edit2.text,a);
- while i<>0 do
- begin
- a:=copy(a,1,i-length(edit2.text))+'***'+copy(a,i+length(edit2.text),maxint);
- i:=pos(edit2.text,a);
- end;
- image1.canvas.textout(x,y,a);}
- i:=pos(edit2.text,a);
- while i<>0 do
- begin
- delete(a,i,length(edit2.text));
- i:=pos(edit2.text,a);
- end;
- image1.canvas.textout(x,y,a);
- end;
- 3:
- begin
- end;
- end;
- end;
- procedure TForm1.Button6Click(Sender: TObject);
- var a2:char;
- begin
- a:=a+1;
- image1.canvas.fillrect(image1.clientrect);
- a2:=edit2.text[1];
- for i:=1 to length(edit1.text)do
- begin
- if a1[i]=a2 then
- a3[i]:=a2;
- end;
- image1.canvas.TextOut(25,25,a3);
- if pos('?',a3)=0 then
- image1.canvas.TextOut(25,45,'stačilo ti '+inttostr(a)+' pokusov.');
- end;
- procedure TForm1.Button7Click(Sender: TObject);
- begin
- a:=0;
- a3:=edit1.text;
- a1:=edit1.text;
- for i:=1 to length(edit1.text) do
- a3[i]:='?';
- image1.canvas.textout(25,25,a3);
- end;
- procedure TForm1.Button8Click(Sender: TObject);
- var b:string;
- cast,n:integer;
- begin
- image1.canvas.fillrect(image1.clientrect);
- b:=edit1.text;
- image1.canvas.textout(25,25,b);
- cast:=strtoint(inputbox('vstup','zadaj čásť úlohy',''));
- case cast of
- 1:
- begin
- for i:=1 to length(b) do
- begin
- if (b[i]>='a') and (b[i]<='y')then
- b[i]:=succ(b[i]);
- if b[i]='z' then
- b[i]:='a';
- end;
- image1.canvas.textout(25,25,b);
- end;
- 2:
- begin
- randomize;
- n:=random(9)+1;
- for i:=1 to length(b) do
- begin
- if (b[i]>char(ord('z')-n)) and (b[i]<='z') then
- b[i]:=char(ord(b[i])-(ord('z')-n+1)+ord('a'));
- //b[i]:=char(ord('a')+((ord('z')-n)-ord(b[i])));
- if (b[i]>='a') and (b[i]<=char(ord('z')-n))then
- b[i]:=char(ord(b[i])+n);
- end;
- image1.canvas.fillrect(image1.clientrect);
- image1.canvas.textout(25,25,b);
- image1.canvas.textout(25,50,inttostr(n));
- end;
- end;
- end;
- procedure TForm1.Button9Click(Sender: TObject);
- begin
- if timer1.enabled=false then
- timer1.enabled:=true
- else
- timer1.enabled:=false;
- end;
- procedure TForm1.Edit1Change(Sender: TObject);
- begin
- end;
- procedure TForm1.Edit2Change(Sender: TObject);
- begin
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement