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 a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
long long a[200],i,n,t;
{
freopen("seq.inp","r",stdin);
freopen("seq.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
for (i=1; i<=n; i++) t=t+a[i];
for (i=1; i<=n; i++)
if ((t%a[i]==0) and (a[i]==t/2))
{
cout<<a[i]<<" ";
return 0;
}
cout<<"N";
return 0;
}
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;
const fi='abc.inp';
var a:array[1..100]of integer;
i,n,dem,j,kt,dem1,dem2:integer;
f1:text;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then inc(dem);
dem1:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then inc(dem1);
end;
dem2:=0;
for i:=1 to n do
if trunc(sqrt(a[i]))=sqrt(a[i]) then inc(dem2);
writeln('So so chan la: ',dem);
writeln('So so nguyen to la: ',dem1);
writeln('So so chinh phuong la: ',dem2);
close(f1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,k,x,a[1000];
int main()
{
cin>>n>>k;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]==k)
{
cout<<"YES";
return 0;
}
cout<<"NO";
return 0;
}
uses crt;
const fi='dlra.txt';
var a:array[1..100]of integer;
i,n,h:integer;
f1:text;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
assign(f1,fi); rewrite(f1);
h:=0;
for i:=1 to n do
if a[i] mod 3<>0 then
begin
write(f1,a[i]:4);
h:=h-a[i];
end;
writeln(f1);
writeln(f1,h);
close(f1);
readln;
end.