Pages - Menu

Kamis, 15 Desember 2011

Program Asistensi


ini nih program yang aku dapat saat asistensi menjelang ETS. bersama kak siapa ya? aku lupa... hehehe...

program kuadratplus;
uses wincrt;
var i,n:integer;
begin
   read(n);
   if n=1 then write (1);
   if n>1 then
   begin
   for i:=n downto 2 do
   write (2*i-1,'+');
   write(1,'=');
   write (sqr(n));
   end;
   end.




 program y_urut;
uses wincrt;
var i,n,j:integer;
begin
read(n);
for i:=1 to n do
begin
for j:= 1 to i do
write (i);
writeln;
end;
end.

 program y_1234;
uses wincrt;
var i,j,n:integer;
begin
read(n);
for i:=1 to n do
begin
for j:= 1 to i do
write (j);
writeln;
end;
end.


program urut;
uses wincrt;
var i,n,j,x:integer;
begin
  read(n);
  x:=1 ;
  for i:= 1 to n do
  begin
  for j:=1to i do
  begin
  write (x);
  inc(x);
  end;
  writeln;
end;
end.

program urut_rata;
uses wincrt;
var i,n,j,x:integer;
begin
  read(n);
  x:=1 ;
  for i:= 1 to n do
  begin
  for j:=1to i do
  begin
  write (x:2,' ');
  inc(x);
  end;
  writeln;
end;
end.

program binomial;
uses wincrt;
var i,n,k,x:integer;
p,cdf:real;
function f(z:integer):real;
begin
k:=1;
for i:=1 to z do
k:=k*i;
f:=k;
end;
function c(y:integer):real;
begin
c:=f(n)/(f(n-y)*f(y));
end;
begin
readln(p,n,x);
cdf:=0;
for i:=0 to x do
cdf:=cdf+c(i)*exp(i*ln(p))*exp((n-1)*ln(1-p));
write(cdf:0:2);

end.

Tidak ada komentar:

Posting Komentar