unit dhoni;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
fortodo: TButton;
fordowntodo: TButton;
whiledo: TButton;
btpangkat: TButton;
repeatuntil: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label7: TLabel;
btkeluar: TButton;
procedure fortodoClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure fordowntodoClick(Sender: TObject);
procedure whiledoClick(Sender: TObject);
procedure repeatuntilClick(Sender: TObject);
procedure btpangkatClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.fortodoClick(Sender: TObject);
var
i,j:integer;
b:string;
begin
b:='';j:=2;
for i:=1 to 10 do
begin
b:=b+inttostr(j)+'';
j:=j+2;
end;
label1.Caption:=b;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.fordowntodoClick(Sender: TObject);
var
i,j:integer;
b:string;
begin
b:='';j:=2;
for i:=10 downto 1 do
begin
b:=b+inttostr(i)+'';
j:=j+2;
end;
label2.Caption:=b;
end;
procedure TForm1.whiledoClick(Sender: TObject);
var
i,j:integer;
b:string;
begin
i:=1;
b:='';
while i<=10 do
begin
b:=b+inttostr(i)+'';
i:=i+1;
end;
label3.Caption:=b;
end;
procedure TForm1.repeatuntilClick(Sender: TObject);
var
i,j:integer;
b:string;
begin
i:=1;
b:='';
repeat
b:=b+inttostr(i)+'';
i:=i+1;
until i>10;
label4.Caption:=b;
end;
procedure TForm1.btpangkatClick(Sender: TObject);
var
bil,hasil,pangkat,a:integer;
begin
bil:=strtoint(edit1.Text);
hasil:=bil;
pangkat:=strtoint(edit2.Text);
if edit2.text='0'then edit3.Text:='1'else
if edit2.text='1'then edit3.Text:=edit1.Text else
begin
for a:=2 to pangkat do
hasil:=hasil*bil;
edit3.Text:=inttostr(hasil);
end;
end;
end.
M. Alif Romadhoni Class 2c n0 35 STIMIK YAdika
Minggu, 06 Mei 2012
Sabtu, 24 Maret 2012
Faktorial ^.^
Program menghitung_faktorial;
uses wincrt;
var
hasil,fak,c,n,nr,r,f1,f2,f3:real;
i:integer;
procedure faktorial(var fak,hasil:real);
begin
i:=1;
hasil:=1;
while i<= fak do
begin
hasil:= hasil*i;
i:=i+1;
end;
writeln(hasil:10:0);
end;
begin
gotoxy(15,1);
writeln('"Program perhitungan Kombinasi pada Faktorial"');
gotoxy(26,15);
writeln('MUCHAMAD ALIF ROMADHONI');
gotoxy(5,3);
write('PLEASE Insert N = ');readln(n);
gotoxy(5,4);
write('PLEASE Insert R = ');readln(r);
nr:= n-r;
gotoxy(5,5);
writeln('NR adalah = ',nr:0:0);
gotoxy(5,7);
write('faktorial dari N =');
faktorial(n,f1);
gotoxy(5,8);
write('faktorial dari R =');
faktorial(r,f2);
gotoxy(5,9);
write('faktorial dari N-R =');
faktorial(nr,f3);
c:=f1/(f3*f2);
write('Hasilnya adalah =',c:10:0);
end.
uses wincrt;
var
hasil,fak,c,n,nr,r,f1,f2,f3:real;
i:integer;
procedure faktorial(var fak,hasil:real);
begin
i:=1;
hasil:=1;
while i<= fak do
begin
hasil:= hasil*i;
i:=i+1;
end;
writeln(hasil:10:0);
end;
begin
gotoxy(15,1);
writeln('"Program perhitungan Kombinasi pada Faktorial"');
gotoxy(26,15);
writeln('MUCHAMAD ALIF ROMADHONI');
gotoxy(5,3);
write('PLEASE Insert N = ');readln(n);
gotoxy(5,4);
write('PLEASE Insert R = ');readln(r);
nr:= n-r;
gotoxy(5,5);
writeln('NR adalah = ',nr:0:0);
gotoxy(5,7);
write('faktorial dari N =');
faktorial(n,f1);
gotoxy(5,8);
write('faktorial dari R =');
faktorial(r,f2);
gotoxy(5,9);
write('faktorial dari N-R =');
faktorial(nr,f3);
c:=f1/(f3*f2);
write('Hasilnya adalah =',c:10:0);
end.
CREATED BY, M. Alif Romadhoni
Jumat, 09 Maret 2012
MATRIKS INVERS ordo 2x2
Misalkan A dan B adalah dua matriks yang berordo 2
× 2 dan memenuhi
persamaan
AB = BA = I2 maka matriks A adalah matriks invers dari
matriks
B atau matriks B adalah matriks invers dari
matriks A.
Contoh Program + Scripnnya :
program matriks_ordo;
uses wincrt;
var
a,b,c,d,i:real;
invers,p,q,r,s:real;
jawab:char;
begin
clrscr;
gotoxy(10,18);
writeln('-----------------------Invers Matriks Ordo 2x2---------------------');
gotoxy(10,5);write('A=');read(a);
gotoxy(18,5);write('B=');read(b);
gotoxy(10,7);write('C=');read(c);
gotoxy(18,7);write('D=');read(d);
i:=(a*d)-(b*c);
if not(i=0) then
begin
invers:=1/((a*d)-(b*c));
p:=d*invers;
q:=-b*invers;
r:=-c*invers;
s:=a*invers;
gotoxy(25,10);writeln('Invers matriks A =');
gotoxy(10,13);write(p:0:3);
gotoxy(18,13);write(q:0:3);
gotoxy(10,16);write(r:0:3);
gotoxy(18,16);write(s:0:3);
end
else
begin
gotoxy(15,5);
writeln('Tidak ada invers matriks');
end;
gotoxy(10,18);
writeln('-------------------------Terimakasih---------------------');
jawab:=readkey;
end.
uses wincrt;
var
a,b,c,d,i:real;
invers,p,q,r,s:real;
jawab:char;
begin
clrscr;
gotoxy(10,18);
writeln('-----------------------Invers Matriks Ordo 2x2---------------------');
gotoxy(10,5);write('A=');read(a);
gotoxy(18,5);write('B=');read(b);
gotoxy(10,7);write('C=');read(c);
gotoxy(18,7);write('D=');read(d);
i:=(a*d)-(b*c);
if not(i=0) then
begin
invers:=1/((a*d)-(b*c));
p:=d*invers;
q:=-b*invers;
r:=-c*invers;
s:=a*invers;
gotoxy(25,10);writeln('Invers matriks A =');
gotoxy(10,13);write(p:0:3);
gotoxy(18,13);write(q:0:3);
gotoxy(10,16);write(r:0:3);
gotoxy(18,16);write(s:0:3);
end
else
begin
gotoxy(15,5);
writeln('Tidak ada invers matriks');
end;
gotoxy(10,18);
writeln('-------------------------Terimakasih---------------------');
jawab:=readkey;
end.
COntoh Aplikasinya :
Created By: M. Alif Romadhoni
Kamis, 08 Maret 2012
Sabtu, 03 Maret 2012
Tugas 2
program MAtrik_identitas_terbalik;
uses
WinCrt;
var
c:array[1..10,1..10] of integer;
X,Y,Z:integer;
begin
for X:=1 to 5 do
begin
for y:=1 to 5 do
begin
c[X,Y]:=0;
if X+Y=6 then C[X,Y]:=1;
write(c[X,Y]:4);
end;
writeln;
end;
end.
uses
WinCrt;
var
c:array[1..10,1..10] of integer;
X,Y,Z:integer;
begin
for X:=1 to 5 do
begin
for y:=1 to 5 do
begin
c[X,Y]:=0;
if X+Y=6 then C[X,Y]:=1;
write(c[X,Y]:4);
end;
writeln;
end;
end.
Tugase P. Hedi Yadika Perkalian
Program Perkalian_Matriks;
uses wincrt;
var
c,d,h:array[1..10,1..10] of integer;
b1,k1,x1,y1,a,b2,k2,x2,y2:longint;
begin;
write('masukkan jumlah baris 1: '); readln(b1);
write('masukkan jumlah kolom 1: '); readln(k1);
for x1:= 1 to b1 do
begin
for y1:= 1 to k1 do
begin
write('[',x1,':',y1,']='); readln(c[x1,y1]);
end;
end;
write('masukkan jumlah baris 2: '); readln(b2);
write('masukkan jumlah kolom 2: '); readln(k2);
for x2:= 1 to b2 do
begin
for y2:=1 to k2 do
begin
write('[',x2,':',y2,']='); readln(d[x2,y2]);
end;
end;
if k1=x2 then begin
writeln('Hasilnya adalah');
for x1:= 1 to b1 do
begin
for a:=1 to k2 do
begin
for y1:= 1 to k1 do
begin
for y2:= a to k2 do
begin
for x2:=y1 to b2 do
begin
h[x1,y2]:=h[x1,y2]+c[x1,y1]*d[x2,y2];
if k1=y1 then
begin
write(h[x1,y2]:7);
end;
x2:=b2;
end;
y2:=k2;
end;
end;
end;
writeln;
end;
end else
begin
writeln('Maaf operasi perkalian matriks tidak bisa dikerjakan !!!');
writeln('karena kolom matriks1 !!! (',k1,' kolom) tidak sama dengan baris matriks 2 !!!(',x2,' baris)');
end;
end.
uses wincrt;
var
c,d,h:array[1..10,1..10] of integer;
b1,k1,x1,y1,a,b2,k2,x2,y2:longint;
begin;
write('masukkan jumlah baris 1: '); readln(b1);
write('masukkan jumlah kolom 1: '); readln(k1);
for x1:= 1 to b1 do
begin
for y1:= 1 to k1 do
begin
write('[',x1,':',y1,']='); readln(c[x1,y1]);
end;
end;
write('masukkan jumlah baris 2: '); readln(b2);
write('masukkan jumlah kolom 2: '); readln(k2);
for x2:= 1 to b2 do
begin
for y2:=1 to k2 do
begin
write('[',x2,':',y2,']='); readln(d[x2,y2]);
end;
end;
if k1=x2 then begin
writeln('Hasilnya adalah');
for x1:= 1 to b1 do
begin
for a:=1 to k2 do
begin
for y1:= 1 to k1 do
begin
for y2:= a to k2 do
begin
for x2:=y1 to b2 do
begin
h[x1,y2]:=h[x1,y2]+c[x1,y1]*d[x2,y2];
if k1=y1 then
begin
write(h[x1,y2]:7);
end;
x2:=b2;
end;
y2:=k2;
end;
end;
end;
writeln;
end;
end else
begin
writeln('Maaf operasi perkalian matriks tidak bisa dikerjakan !!!');
writeln('karena kolom matriks1 !!! (',k1,' kolom) tidak sama dengan baris matriks 2 !!!(',x2,' baris)');
end;
end.
Langganan:
Postingan (Atom)