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 1:
uses crt;
var m,n,ucln,i:integer;
begin
clrscr;
write('Nhap m='); readln(m);
write('Nhap n='); readln(n);
ucln:=1;
if m<n then
begin
for i:=1 to m do
if (m mod i=0) and (n mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end
else begin
for i:=1 to n do
if (m mod i=0) and (n mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end;
writeln(ucln);
readln;
end.
Câu 2:
uses crt;
var m,n,bcnn,i:integer;
begin
clrscr;
write('Nhap m='); readln(m);
write('Nhap n='); readln(n);
bcnn:=m*n;
for i:=m*n-1 downto 1 do
if (i mod m=0) and (i mod n=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln(bcnn);
readln;
end.
uses crt;
var i,n,m,k,d:integer;
{---------------chuong-trinh-con-tim-ucln--------------------}
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;
{------------chuong-trinh-con-kiem-tra-so-nguyen-to-------------------}
function nt(b:longint):boolean;
var j:longint;
begin
nt:=true;
if (b=2) or (b=3) then exit;
nt:=false;
if (b=1) or (b mod 2=0) or (b mod 3=0) then exit;
j:=5;
while j<=trunc(sqrt(b)) do
begin
if (b mod j=0) or (b mod (j+2)=0) then exit;
j:=j+6;
end;
nt:=true;
end;
{---------------chuong-trinh-chinh---------------------}
begin
clrscr;
write('Nhap N: '); readln(N);
write('Nhap M: '); readln(M);
d:=0;
k:=ucln(N,M);
for i:=1 to k do
if nt(i) then d:=d+1;
if d>0 then writeln('2 so nay tuong duong voi nhau')
else writeln('2 so nay khong tuong duong voi nhau');
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.
program UocChungLonNhat;
var
a, b: integer;
function UCLN(a, b: integer): integer;
begin
if b = 0 then
UCLN := a
else
UCLN := UCLN(b, a mod b);
end;
begin
write('Nhập số nguyên dương a: ');
readln(a);
write('Nhập số nguyên dương b: ');
readln(b);
writeln('UCLN của ', a, ' và ', b, ' là ', UCLN(a, b));
end.
uses crt;
var a:array[1..100]of integer;
i,n,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long m,n,t,i;
int main()
{
freopen("dulieu.inp","r",stdin);
freopen("ketqua.out","w",stdout);
cin>>m>>n;
t=0;
for (i=m; i<=n; i++)
if (i%2!=0) t+=i;
cout<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
m,n,dem,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap m='); readln(m);
dem:=0;
for i:=1 to n do
if a[i]=m then inc(dem);
writeln('So phan tu bang ',m,' la: ',dem);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
uses crt;
var n,i,m,max:integer;
function kt(n:integer):integer;
var j,k:integer
begin
k:=0;
for j:=2 to n do
if (n mod j)=0 then k:=k+1;
kt:=k+1;
end;
begin
readln(n);
if n=1 then write(1)
else
begin
max:=kt(2);
for m:=3 to n do
if max<kt(m) then max:=kt(m);
write(max);
end;
end.