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.
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.
Câu 1:
const fi1='nguyen1.inp';
fi2='nguyen2.inp';
fo='songuyen.inp';
var f1,f2,f3:text;
a:array[1..10000]of integer;
i,dem:integer;
begin
assign(f1,fi1); reset(f1);
assign(f2,fi2); reset(f2);
assign(f3,fo); rewrite(f3);
dem:=0;
while not eof(f1) do
begin
inc(dem);
read(f1,a[dem]);
end;
while not eof(f2) do
begin
inc(dem);
read(f2,a[dem]);
end;
for i:=1 to dem do
write(f3,a[i]:4);
close(f1);
close(f2);
close(f3);
end.
Câu 2:
uses crt;
const fi='vanban.txt';
var f1:text;
st:array[1..255]of string;
dem:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
dem:=0;
while not eof(f1) do
begin
inc(dem);
readln(f1,st[dem]);
end;
writeln('So dong cua tep ',fi,' la: ',dem);
close(f1);
readln;
end.
Câu 3:
const fi='nguon.txt';
fo='dich.txt';
var f1,f2:text;
st:array[1..255]of string;
i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eof(f1) do
begin
inc(dem);
readln(f1,st[dem]);
end;
for i:=1 to dem do
writeln(f2,st[i]:4);
close(f1);
close(f2);
end.
Câu 4:
const fi='dulieu.int';
fo='sochan.out';
var f1,f2:text;
a:array[1..255]of integer;
i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eoln(f1)do
begin
inc(dem);
read(f1,a[dem]);
end;
for i:=1 to dem do
if a[i] mod 2=0 then write(f2,a[i]:4);
close(f1);
close(f2);
end.
Câu 5:
const fi='dulieu.int';
fo='dulieu.out';
var f1,f2:text;
a:array[1..255]of integer;
i,n,tam,j: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]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(f2,a[i]:4);
close(f1);
close(f2);
end.
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.
#include <bits/stdc++.h>
using namespace std;
long long i,a[100],n;
int main()
{
freopen("songuyen.txt","r",stdin);
n=20;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
with open('XAU.INP', 'r') as input_file, open('XAU.OUT', 'w') as output_file:
for line in input_file:
length = len(line.strip())
output_file.write(f'{length}\n')