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.
const fi='tong.inp';
fo='tong.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,t: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
t:=t+a[i];
writeln(f2,t);
close(f1);
close(f2);
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.
uses crt;
const fi='baitap.txt';
var f1:text;
a:array[1..100]of integer;
n,i:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln(f1,n);
for i:=1 to n do
write(f1,a[i]:4);
close(f1);
readln;
end.
const fi='xsum1.inp';
fo='xsum1.out';
var f1,f2:text;
a:array[1..20000]of integer;
i,n,j,x,dem,k,m,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n,x);
for i:=1 to n do
read(f1,a[i]);
dem:=0;
for i:=1 to n do
for j:=1 to n do
begin
for k:=1 to n do
if (i<j) and (j<k) then
begin
t:=0;
for m:=i to k do
t:=t+a[m];
if t=x then inc(dem);
end;
end;
for i:=1 to n do
if x=a[i] then inc(dem);
writeln(f2,dem);
close(f1);
close(f2);
end.
program COST;
var n,m,s,dem:int64;a:
array[1..1000000] of int64;
i,j:longint;
begin
readln(n,m);
for i := 1 to n do read(a[i]);
dem := 0;
for i := 1 to n do
begin
s := 0;
for j := i to n do
begin
s := s+a[j];
if s <= m then
begin
inc(dem);
continue;
end
else if a[j] > m then break;
end;
end;
write(dem);
end.
program lake;
uses crt;
var n,t,i:integer;
s,a,b:longint;
begin
clrscr;
readln(n,t);
s:=0;
for i:=1 to n do begin
readln(a,b);
s:=s+a-b*t;
end;
write(s);
readln
end.