program determinan;
uses wincrt;
var A : array[1..2,1..2] of integer;
j,k,D : integer;
begin
For j:=1 to 2 do
begin
write('Entrikan baris ',j,' matriks A : ');
readln(A[j,1] , A[j,2]);
end;
For j:=1 to 2 do
begin
For k:=1 to 2 do write(A[j,k] : 5);
writeln;
end;
writeln;writeln;writeln;
D := A[1,1]*A[2,2] - A[1,2]*A[2,1];
writeln('Det(A) = ',D);
end.
Kamis, 05 Januari 2012
MODUS
program terbanyak;
uses wincrt;
var i,n,j,modus:integer;
A,frek:array[1..100] of integer;
begin
readln(n);
for i:=1 to n do
readln(A[i]);
writeln;
for i:=1 to n-1 do
begin
for j:=i+1 to n do
if A[i]=A[j] then
frek[i]:=frek[i]+1;
end;
modus:=1;
for i:=1 to n do
begin
if frek[modus]<frek[i] then
modus:=i;
end;
write('Modus: ',A[modus],' sejumlah ',frek[modus]+1);
end.
uses wincrt;
var i,n,j,modus:integer;
A,frek:array[1..100] of integer;
begin
readln(n);
for i:=1 to n do
readln(A[i]);
writeln;
for i:=1 to n-1 do
begin
for j:=i+1 to n do
if A[i]=A[j] then
frek[i]:=frek[i]+1;
end;
modus:=1;
for i:=1 to n do
begin
if frek[modus]<frek[i] then
modus:=i;
end;
write('Modus: ',A[modus],' sejumlah ',frek[modus]+1);
end.
Konversi Angka
Program konversi_biner;
uses wincrt;
var
desimal,b,sisa,biner:integer;
begin
write (' angka biner '); readln (biner);
b:=0;
repeat
sisa:= biner mod 10;
biner:= biner div 10;
if (b=0) then
b:=1
else
b:=b*2;
desimal:= desimal+sisa*b;
until biner = 0;
write ('desimal=', desimal );
end.
uses wincrt;
var
desimal,b,sisa,biner:integer;
begin
write (' angka biner '); readln (biner);
b:=0;
repeat
sisa:= biner mod 10;
biner:= biner div 10;
if (b=0) then
b:=1
else
b:=b*2;
desimal:= desimal+sisa*b;
until biner = 0;
write ('desimal=', desimal );
end.
Langganan:
Postingan (Atom)