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.
Program hotrotinhoc;
const fi='cau2.inp';
fo='cau2.out';
var f: text;
s: ansistring;
i,n,d,max,min: integer;
a: array[1..1000] of string;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,s);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
s:=s+' ';
while length(s)<>0 do
begin
inc(d);
min:=1001;
max:=0;
a[d]:=copy(s,1,pos(' ',s)-1);
delete(s,1, pos(' ',s));
end;
for i:=1 to d do
begin
if length(a[i])>max then max:=length(a[i]);
if length(a[i])<min then min:=length(a[i]);
end;
write(f,min,' ',max);
close(f);
end;
begin
ip;
out;
end.
Program hotrotinhoc_hoc24;
const fi='CAPSO.INP';
fo='CAPSO.OUT';
var a: array[1..100] of integer;
i,j,n,x,d: integer;
f: text;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
readln(f);
read(f,x);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
d:=0;
for i:=1 to n do
for j:=i to n do
if i+j=x then inc(d);
write(f,d);
close(f);
end;
begin
ip;
out;
end.
Program HOC24;
const fi='Cau1.INP';
fo='Cau2.OUT';
var i,a,b,c,t,d: integer;
f: text;
function ucln(x,y: integer): integer;
var t: integer;
begin
while y<>0 do
begin
t:= x mod y;
x:=y;
y:=t;
end;
ucln:=x;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,b,c);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
for i:=b to c do
begin
if i mod a=0 then write(f,i,' ');
t:=t+i;
end;
writeln(f);
while t<>0 do
begin
t:=t div 10;
inc(d);
end;
writeln(f,d);
if ucln(a,b,c)=1 then write(f,1) else write(f,0);
close(f);
end;
begin
ip;
out;
end.
Bài 2:
-Sum(a1,b1,30): 110
-sum(a1,a1,b1): 110
-Average(a1,b1,50): 43,(3)
-Max(a1,b1,25): 50
Bài 1:
const fi='robot.inp';
fo='robot.out';
var f1,f2:text;
n,i,t:integer;
a:array[1..10000]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
t:=0;
for i:=1 to n do
begin
if a[i]=1 then t:=t+1
else t:=t-1;
end;
writeln(f2,t);
close(f1);
close(f2);
end.