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.
int BCNN(int a, int b)
{
int result = UCLN(a, b);
return a * b / result;
}
int main()
{
int a, b; cout << "a = ";
cin >> a;
cout << "b = ";
cin >> b;
int result = UCLN(a, b);
cout << "UCLN : "<<result; cout << "\n";
result = BCNN(a, b);
cout << "BCNN : " << result << endl;
system("pause");
}
Biết viết mỗi C++, Pascal thì miss gần hết :(
uses crt;
var a,b,bcnn,i:longint;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
bcnn:=a*b;
for i:=a*b-1 downto 1 do
if (i mod a=0) and (i mod b=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln('Boi chung nho nhat la: ',bcnn);
readln;
end.
uses crt;
var a:array[1..250]of integer;
n,i,t,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac so la boi cua 3 la: ',t);
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 a[1000],i,n,t,nn,x;
int main()
{
freopen("lop11a.inp","r",stdin);
freopen("kq.txt","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
nn=LLONG_MAX;
for (i=1;i<=n; i++)
if (100<=a[i] && a[i]<=999)
{
nn=min(nn,a[i]);
}
cout<<nn<<endl;
t=0;
while (nn>0)
{
x=nn%10;
t=t+x;
nn=nn/10;
}
cout<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
n,dem,i,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n do
begin
dem:=0;
for j:=1 to a[i] do
if a[i] mod j=0 then inc(dem);
if dem mod 2=0 then write('0 ')
else write('1 ');
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,ln,t,k,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
ln=LLONG_MIN;
for (i=1; i<=n; i++) ln=max(ln,a[i]);
cout<<"So lon nhat la: "<<ln<<endl;
cout<<"VI tri la: ";
for (i=1; i<=n; i++) if (ln==a[i]) cout<<i<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++)
if (a[i]>0) t+=a[i];
cout<<"Tong cac so duong la: "<<t<<endl;
cin>>k;
for (i=1; i<=n; i++)
if (a[i]%k==0) cout<<a[i]<<" ";
cout<<endl;
nn=LLONG_MAX;
for (i=1; i<=n; i++)
nn=min(nn,a[i]);
cout<<nn;
return 0;
}
Bài 2:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
if (i mod 3=0) and (i mod 5=0) then t:=t+i;
writeln(t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,k,max,min,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Gia tri lon nhat la: ',max);
writeln('Vi tri la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
writeln;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('Gia tri nho nhat la: ',min);
writeln('Vi tri la: ');
for i:=1 to n do
if min=a[i] then write(i:4);
writeln;
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+sqr(a[i]);
writeln('Tong binh phuong cac gia tri o vi tri chan la: ',t);
readln;
end.
Program HOC24;
var a,b,c,d: integer;
Begin
write('Nhap a: '); readln(a);
write('Nhap b: '); readln(b);
write('Nhap c: '); readln(c);
write('Nhap d: '); readln(d);
if (a=0) or (b=0) or (c=0) or (d=0) then write('Tich 4 so bang 0');
if a*b*c*d>0 then write('Tich 4 so do la so duong');
if a*b*c*d<0 then write('Tich 4 so do la so am');
readln
end.