Advertisement
Guest User

dnjksdkjbfduiofbuif

a guest
Nov 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 7.44 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   ExtCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Button2: TButton;
  18.     Button3: TButton;
  19.     Button4: TButton;
  20.     Button5: TButton;
  21.     Button6: TButton;
  22.     Button7: TButton;
  23.     Button8: TButton;
  24.     Button9: TButton;
  25.     Edit1: TEdit;
  26.     Edit2: TEdit;
  27.     Image1: TImage;
  28.     Timer1: TTimer;
  29.     procedure Button1Click(Sender: TObject);
  30.     procedure Button2Click(Sender: TObject);
  31.     procedure Button3Click(Sender: TObject);
  32.     procedure Button4Click(Sender: TObject);
  33.     procedure Button5Click(Sender: TObject);
  34.     procedure Button6Click(Sender: TObject);
  35.     procedure Button7Click(Sender: TObject);
  36.     procedure Button8Click(Sender: TObject);
  37.     procedure Button9Click(Sender: TObject);
  38.     procedure Edit1Change(Sender: TObject);
  39.     procedure Edit2Change(Sender: TObject);
  40.     procedure FormCreate(Sender: TObject);
  41.     procedure Timer1Timer(Sender: TObject);
  42.   private
  43.     { private declarations }
  44.   public
  45.     { public declarations }
  46.   end;
  47.  
  48. var
  49.   Form1: TForm1;
  50.   a1,a3:string;
  51.   i,a,xx,yy,xxx,yyy:integer;
  52. implementation
  53.  
  54. {$R *.lfm}
  55.  
  56. { TForm1 }
  57.  
  58. procedure TForm1.FormCreate(Sender: TObject);
  59. begin
  60.   image1.canvas.fillrect(image1.clientrect);
  61.   a:=0;
  62.   a3:=edit1.text;
  63.   a1:=edit1.text;
  64.   for i:=1 to length(edit1.text) do
  65.   a3[i]:='?';
  66.   image1.canvas.textout(25,25,a3);
  67.   xx:=10;
  68.   yy:=10;
  69. end;
  70.  
  71. procedure TForm1.Timer1Timer(Sender: TObject);
  72. var slovo:string;
  73. begin
  74. image1.canvas.fillrect(image1.clientrect);
  75. slovo:=edit1.text;
  76. if (xx<image1.width) and (yy<image1.Height) then
  77. begin
  78. image1.canvas.textout(xx,yy,slovo);
  79. xx:=xx+25;
  80. yy:=yy+25;
  81. xxx:=xx;
  82. yyy:=yy;
  83. end
  84. else
  85. begin
  86. for i:=1 to length(slovo) do
  87. begin
  88. image1.canvas.textout(xxx,yyy,slovo[i]);
  89. randomize;
  90. image1.canvas.Font.color:=random(256*256*256);
  91. xxx:=xxx-random(25);
  92. yyy:=yyy-random(25);
  93. end;
  94. end;
  95. end;
  96.  
  97. procedure TForm1.Button1Click(Sender: TObject);
  98. var a:char;
  99.     i,x,y:integer;
  100. begin
  101.   x:=15;
  102.   y:=15;
  103.   for i:=1 to 256 do
  104.   begin
  105.     a:=char(i-1);
  106.     image1.canvas.textout(x,y,a + '=' + inttostr(i-1));
  107.     y:=y+15;
  108.     if y+20>image1.Height then
  109.     begin
  110.       y:=15;
  111.       x:=x+40;
  112.     end;
  113.   end;
  114. end;
  115.  
  116. procedure TForm1.Button2Click(Sender: TObject);
  117.  var a:string;
  118.      i,slovo,veta,velke,male,cisla:integer;
  119. begin
  120.   a:=edit1.text;
  121.   slovo:=1;
  122.   veta:=0;
  123.   velke:=0;
  124.   male:=0;
  125.   cisla:=0;
  126.   for i:=1 to length(a) do
  127.   begin
  128.     if a[i]=' ' then
  129.     slovo:=slovo+1;
  130.     if (a[i]='.') or (a[i]='?') or (a[i]='!') then
  131.     veta:=veta+1;
  132.     if (a[i]>='A') and (a[i]<='Z') then
  133.     velke:=velke+1;
  134.     if (a[i]>='a') and (a[i]<='z') then
  135.     male:=male+1;
  136.     if (a[i]>='0') and (a[i]<='9') then
  137.     cisla:=cisla+1;
  138.   end;
  139.   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]));
  140. end;
  141.  
  142. procedure TForm1.Button3Click(Sender: TObject);
  143.  var a,slovo:string;
  144.      x,y,i:integer;
  145. begin
  146.   a:=edit1.text;
  147.   y:=25;
  148.   x:=25;
  149.   image1.canvas.textout(x,y,a);
  150.   y:=y+50;
  151.   for i:=1 to length(a) do
  152.   begin
  153.     if a[i]<>' ' then
  154.       slovo:=slovo+a[i]
  155.     else
  156.     begin
  157.       image1.canvas.textout(x,y,slovo);
  158.       slovo:=' ';
  159.       y:=y+25;
  160.     end;
  161.   end;
  162.   image1.canvas.textout(x,y,slovo);
  163. end;
  164.  
  165. procedure TForm1.Button4Click(Sender: TObject);
  166.  var a,slovo,reverse:string;
  167.      x,y,i,j:integer;
  168. begin
  169.   a:=edit1.text;
  170.   reverse:=' ';
  171.   y:=25;
  172.   x:=25;
  173.   image1.canvas.textout(x,y,'pôvodne slovo je: '+a);
  174.   y:=y+25;
  175.   for i:=1 to length(a) do
  176.   begin
  177.     if (a[i]<>' ') and (a[i]<>'.') and (a[i]<>',') and (a[i]<>'?') and (a[i]<>'!') then
  178.       slovo:=slovo+a[i]
  179.     else
  180.     begin
  181.       for j:=1 to length(slovo) do
  182.       reverse:=reverse+slovo[length(slovo)-j+1];
  183.       reverse:=reverse+a[i];
  184.       slovo:=' ';
  185.     end;
  186.   end;
  187.   for j:=1 to length(slovo) do
  188.   reverse:=reverse+slovo[length(slovo)-j+1];
  189.   image1.canvas.textout(x,y,'obrátené slovo je: '+ reverse);
  190. end;
  191.  
  192. procedure TForm1.Button5Click(Sender: TObject);
  193. const samohlasky='aeiou';
  194. var a:string;
  195.     b:char;
  196.     i,j,x,y,zadanie:integer;
  197. begin
  198.   zadanie:=strtoint(inputbox('vstup','zadaj cast ulohy',''));
  199.   a:=edit1.text;
  200.   x:=25;
  201.   y:=25;
  202.   image1.canvas.textout(x,y,'pôvodna veta je: '+a);
  203.   case zadanie of
  204.   1:
  205.   begin
  206.     for i:=1 to length(samohlasky) do
  207.     begin
  208.       b:=samohlasky[i];
  209.       for j:= 1 to length(a) do
  210.       begin
  211.          if (a[j]='a') or (a[j]='e') or (a[j]='i') or (a[j]='o') or (a[j]='u') then
  212.          a[j]:=b;
  213.       end;
  214.       y:=y+25;
  215.       image1.canvas.textout(x,y,a);
  216.     end;
  217.   end;
  218.   2:
  219.   begin
  220.   image1.canvas.fillrect(image1.clientrect);
  221.   {for i:=1 to length(a) do
  222.     begin
  223.       if a[i]=' ' then
  224.       a[i]:='*';
  225.     end;
  226.   y:=y+25;
  227.   image1.canvas.textout(x,y,a);}
  228.  
  229.   {i:=pos(' ',a);
  230.   while i<>0 do
  231.   begin
  232.     a:=copy(a,1,i-1)+'***'+copy(a,i+1,maxint);
  233.     i:=pos(' ',a);
  234.   end;
  235.   image1.canvas.textout(x,y,a);}
  236.  
  237.   {i:=pos(edit2.text,a);
  238.     while i<>0 do
  239.     begin
  240.       a:=copy(a,1,i-length(edit2.text))+'***'+copy(a,i+length(edit2.text),maxint);
  241.       i:=pos(edit2.text,a);
  242.     end;
  243.     image1.canvas.textout(x,y,a);}
  244.  
  245.   i:=pos(edit2.text,a);
  246.   while i<>0 do
  247.   begin
  248.      delete(a,i,length(edit2.text));
  249.      i:=pos(edit2.text,a);
  250.    end;
  251.    image1.canvas.textout(x,y,a);
  252.   end;
  253.   3:
  254.   begin
  255.  
  256.   end;
  257.   end;
  258. end;
  259.  
  260. procedure TForm1.Button6Click(Sender: TObject);
  261. var a2:char;
  262. begin
  263.   a:=a+1;
  264.   image1.canvas.fillrect(image1.clientrect);
  265.   a2:=edit2.text[1];
  266.   for i:=1 to length(edit1.text)do
  267.   begin
  268.     if a1[i]=a2 then
  269.     a3[i]:=a2;
  270.   end;
  271.   image1.canvas.TextOut(25,25,a3);
  272.   if pos('?',a3)=0 then
  273.   image1.canvas.TextOut(25,45,'stačilo ti '+inttostr(a)+' pokusov.');
  274. end;
  275.  
  276. procedure TForm1.Button7Click(Sender: TObject);
  277. begin
  278.   a:=0;
  279.   a3:=edit1.text;
  280.   a1:=edit1.text;
  281.   for i:=1 to length(edit1.text) do
  282.   a3[i]:='?';
  283.   image1.canvas.textout(25,25,a3);
  284. end;
  285.  
  286. procedure TForm1.Button8Click(Sender: TObject);
  287. var b:string;
  288.     cast,n:integer;
  289. begin
  290.   image1.canvas.fillrect(image1.clientrect);
  291.   b:=edit1.text;
  292.   image1.canvas.textout(25,25,b);
  293.   cast:=strtoint(inputbox('vstup','zadaj čásť úlohy',''));
  294.   case cast of
  295.   1:
  296.   begin
  297.     for i:=1 to length(b) do
  298.     begin
  299.        if (b[i]>='a') and (b[i]<='y')then
  300.        b[i]:=succ(b[i]);
  301.        if b[i]='z' then
  302.        b[i]:='a';
  303.     end;
  304.     image1.canvas.textout(25,25,b);
  305.   end;
  306.   2:
  307.   begin
  308.     randomize;
  309.     n:=random(9)+1;
  310.     for i:=1 to length(b) do
  311.       begin
  312.         if (b[i]>char(ord('z')-n)) and (b[i]<='z') then
  313.         b[i]:=char(ord(b[i])-(ord('z')-n+1)+ord('a'));
  314.         //b[i]:=char(ord('a')+((ord('z')-n)-ord(b[i])));
  315.         if (b[i]>='a') and (b[i]<=char(ord('z')-n))then
  316.         b[i]:=char(ord(b[i])+n);
  317.       end;
  318.     image1.canvas.fillrect(image1.clientrect);
  319.     image1.canvas.textout(25,25,b);
  320.     image1.canvas.textout(25,50,inttostr(n));
  321.     end;
  322.   end;
  323. end;
  324.  
  325. procedure TForm1.Button9Click(Sender: TObject);
  326. begin
  327.   if timer1.enabled=false then
  328.   timer1.enabled:=true
  329.   else
  330.   timer1.enabled:=false;
  331. end;
  332.  
  333. procedure TForm1.Edit1Change(Sender: TObject);
  334. begin
  335.  
  336. end;
  337.  
  338. procedure TForm1.Edit2Change(Sender: TObject);
  339. begin
  340.  
  341. end;
  342.  
  343. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement