ΠΡΟΣΘΕΣΗ ΔΙΑΔΟΧΙΚΏΝ ΑΡΙΘΜΏΝ ΣΕ EMBARCADERO DELPHI.
unit SumTwoOk;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.Edit, FMX.StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
var
sum, million, hundred,hundredT, tenT, tausend,decade,balance,ten, one, n1: Integer;
begin
n1:=StrToInt(Edit1.Text);
million := n1 div 1000000;
balance := n1 mod 1000000;
hundredT := balance div 100000;
balance := n1 mod 100000;
tenT := balance div 10000;
balance := n1 mod 10000;
tausend := balance div 1000;
balance := n1 mod 1000;
hundred := balance div 100;
balance := n1 mod 100;
ten := balance div 10;
balance := n1 mod 10;
one := balance div 1;
balance := n1 mod 1;
sum:=million+hundredT+tenT+tausend+hundred+ten+one;
showmessage(IntToStr(sum));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text:=’ ‘;
// Edit2.Text:=’ ‘;
// Edit3.Text:=’ ‘;
// Edit4.Text:=’ ‘;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
s,y,d,m,yy,youa,getdate: string;
d1,m1,y1,y2, sumstr:Integer;
begin
s := FormatDateTime(‘dd.mm.yyyy’, now);
d := copy(s, 1, 2);
m := copy(s, 4, 2);
y := copy(s, 7, 2);
yy := copy(s, 9, 2);
d1:=StrToInt(d);
m1:=StrToInt(m);
y1:=StrToInt(y);
y2:=StrToInt(yy);
sumstr:=d1+m1+y1+y2;
youa:=IntToStr(sumstr);
Label1.Text:=IntToStr(sumstr);
getdate := FormatDateTime(‘dd.mm.yyyy’, now);
Label2.Text:=FormatDateTime(‘dd.mm.yyyy’, now);
end;
end.