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.
#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;
}
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,kt,max,x,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Mang ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
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;
writeln('Day tang dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
write('Nhap x='); readln(x);
max:=0;
kt:=0;
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]<=x) then
begin
if max<a[i] then max:=a[i];
kt:=1;
end;
if kt=0 then writeln('Trong day khong co so le')
else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[10000];
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 a,vtmax,vtmin:array[1..100]of integer;
n,i,max,min,dem,t,dem1,t1,dem2,t2,dem3,t3,dem4,t4,k: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];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('So lon nhat trong day la: ',max);
dem:=0;
t:=0;
for i:=1 to n do
if max=a[i] then
begin
inc(dem);
t:=t+a[i];
vtmax[dem]:=i;
end;
if dem>1 then
begin
writeln('Tong cac so max la: ',t);
writeln('Cac vi tri co so max la: ');
for i:=1 to dem do
write(vtmax[i]:4);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('So nho nhat trong day la: ',min);
dem1:=0;
t1:=0;
for i:=1 to n do
if min=a[i] then
begin
inc(dem1);
t1:=t1+a[i];
vtmin[dem1]:=i;
end;
if dem1>1 then
begin
writeln('Tong cac so min la: ',t1);
writeln('Cac vi tri co so min la: ');
for i:=1 to dem1 do
write(vtmin[i]:4);
end;
write('Nhap k='); readln(k);
dem2:=0;
t2:=0;
for i:=1 to n do
if (i mod 2=0) and (a[i] mod k=0) then
begin
dem2:=dem2+1;
t2:=t2+a[i];
end;
writeln('So phan tu o vi tri chan trong day la boi cua ',k,' la: ',dem2);
writeln('Tong cac so o vi tri chan trong day la boi cua ',k,' la: ',t2);
dem3:=0;
t3:=0;
for i:=1 to n do
if (i mod 2=1) and (k mod a[i]=0) then
begin
inc(dem3);
t3:=t3+a[i];
end;
writeln('So phan tu o vi tri le trong day la uoc cua ',k,' la: ',dem3);
writeln('Tong cac so o vi tri le trong day la uoc cua ',k,' la: ',t3);
dem4:=0;
t4:=0;
for i:=1 to n do
if (a[i]+k=1) or (a[i]=k+1) then
begin
inc(dem4);
t4:=t4+a[i];
end;
writeln('So phan tu la anh em cua ',k,' trong day la: ',dem4);
writeln('Tong cac phan tu la anh em cua ',k,' trong day la: ',t4);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,max: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];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
cau 1:
uses crt;
var a:array[1..100] of integer;
n,i,min: integer;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
min:=a[1];
for i:=2 to n do
if min>a[i] then min=a[i];
writeln(a[i]);
readln;
end.
cau 2:
uses crt;
g:text;
s:string;
const fo='CHUSO.TXT';
begin
assign(g,fo);
rewrite(g);
readln(s);
for i:=1 to length(s) do
if not((s[i] in ['a'..'z'])and(s[i] in ['A'..'Z])) then delete(s,i,1);
writeln(g,s);
end.
Bài 1:
uses crt;
var a:array[1..200]of integer;
i,n,t: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 5=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 5 la: ',t);
readln;
end.
Bài 2:
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(st);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,t,nn,kt:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=1;
for i:=1 to n do
if a[i] mod 3=0 then t:=t*a[i];
writeln(t);
kt:=0;
nn:=32567;
for i:=1 to n do
if a[i] mod 3=0 then
begin
if nn>a[i] then nn:=a[i];
kt:=1;
end;
if kt=0 then writeln('Khong co so chia het cho 3')
else writeln('So nho nhat chia het cho 3 la: ',nn);
for i:=1 to n do
if nn=a[i] then write(i:4);
writeln;
for i:=n downto 1 do
write(a[i]:4);
readln;
end.
mảnh đó bao nhiêu phần tử