Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
a)
PROGRAM BAI1a;
VAR N, Tle, Tchan: integer;
BEGIN
Write ('Nhap N =');
Readln (N);
If (N mod 2) = 0 Then
Tle := N*((N - 2)/2 + 1)/2;
Tchan := (N + 2)*((N - 2)/2 + 1)/2;
If (N mod 2) = 1 Then
Tle := (N + 1)*((N-1)/2 +1)/2;
Tchan := (N + 1)*((N - 3)/2 + 1)/2;
WRITELN ('Sle =', Sle, 'Schan =', Schan);
READLN;
END.
Câu 2:
uses crt;
var a,b:integer;
{-----------------chuong-trinh-con-------------------}
function ucln(x,y:integer):integer;
var i,uc:integer;
begin
if x<y then
begin
uc:=1;
for i:=1 to x do
if (x mod i=0) and (y mod i=0) then
begin
if uc<i then uc:=i;
end;
end
else begin
uc:=1;
for i:=1 to y do
if (x mod i=0) and (y mod i=0) then
begin
if uc<i then uc:=i;
end;
end;
ucln:=uc;
end;
{--------------------------chuong-trinh-chinh------------------------}
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
writeln(a,'/',b,'=',a div ucln(a,b),'/',b div ucln(a,b));
readln;
end.
Câu 1:
const fi='songuyen.inp';
fo='tong.out';
var f1,f2:text;
a:array[1..100]of integer;
i,n,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eoln(f1) do
begin
n:=n+1;
read(f1,a[n]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(f2,t);
close(f1);
close(f2);
end.
const fi='tamgiac.dat';
fo='tamgiac.out';
var f1,f2:text;
a,b,c,d,e,f:array[1..100]of integer;
i,n,dem1,dem2,dem3:integer;
ab,bc,ac:real;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
readln(f1,a[i],b[i],c[i],d[i],e[i],f[i]);
dem1:=0;
dem2:=0;
dem3:=0;
for i:=1 to n do
begin
ab:=sqrt(sqr(a[i]-c[i])+sqr(b[i]-d[i]));
ac:=sqrt(sqr(a[i]-e[i])+sqr(b[i]-f[i]));
bc:=sqrt(sqr(c[i]-e[i])+sqr(d[i]-f[i]));
if (ab>0) and (ac>0) and (bc>0) and (ab+ac>bc) and (ab+bc>ac) and
(ac+bc>ab) then
begin
if (ab=ac) or (ac=bc) then inc(dem1);
if ((ab=ac) and (ab<>bc) and (ac<>bc)) then inc(dem2);
if ((ac=bc) and (bc<>ab) and (ac<>ab)) then inc(dem2);
if ((ac=bc) and (ac<>ab) and (bc<>ab)) then inc(dem2);
if sqr(ab)=sqr(ac)+sqr(bc) then inc(dem3);
if sqr(ac)=sqr(bc)+sqr(ab) then inc(dem3);
if sqr(bc)=sqr(ab)+sqr(ac) then inc(dem3);
end;
end;
writeln(f2,dem1);
writeln(f2,dem2);
writeln(f2,dem3);
close(f1);
close(f2);
end.