K
Khách

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;

int n,A[100],i,dem=0;

int main()

{

cin>>n;

for (int i=1; i<=n; i++) cin>>A[i];

sort(A+1,A+n+1);

for (int i=1; i<=n; i++)

cout<<A[i]<<" ";

cout<<endl;

for (int i=1; i<=n; i++)

if (A[i]%2==0) dem++;

cout<<dem;

}

#include <bits/stdc++.h>

using namespace std;

long long a[1000],dem1,dem2,i,n;

int main()

{

cin>>n;

dem1=0;

dem2=0;

for (i=1; i<=n; i++)

{

cin>>a[i];

if (a[i]%2==0) dem1++;

else dem2++;

}

cout<<dem1<<" "<<dem2<<endl;

sort(a+1,a+n+1);

for (i=n; i>=1; i--) cout<<a[i]<<" ";

return 0;

}

24 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[1000];

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

sort(a+1,a+n+1);

for (i=n; i>=1; i--) cout<<a[i]<<" ";

return 0;

}

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.

2: 

uses crt;

var a:array[1..100]of integer;

i,n,j,tam: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-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(a[i]:4);

readln;

end.

3:

uses crt;

var x,i,max:integer;

begin

clrscr;

repeat

write('Nhap x='); readln(x);

until x>0;

max:=0;

for i:=1 to x do 

  if i mod 2=0 then

begin

if max<=i then max:=i;

end;

writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);

readln;

end.

13 tháng 3 2021

Program HOC24;

var a: array[1..32000] of integer;

i,n,tg,c,l: integer;

tc,tl: longint;

begin

write('Nhap N: '); readln(n);

c:=0; l:=0; tc:=0; tl:=0;

for i:=1 to n do

begin

write('Nhap so thu ',i,': '); readln(a[i];

if a[i] mod 2=0 then

begin

c:=c+1;

tc:=tc+a[i];

end;

if a[i] mod 2=1 then

begin

l:=l+1;

tl:=tl+a[i];

end;

end;

write('Day da sap xep: ');

for i:=1 to n do if a[i] mod 2=1 then write(a[i],' ');

for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');

writeln;

wirteln('Co ',l,' so le');

writeln('Co ',c,' so chan');

writeln('Tong cac so le la: ',tl);

writeln('Tong cac so chan la:', tc);

readln

end.

13 tháng 3 2023

Var so,n,i:integer;

s:longint;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');readln(so);

If (so mod 3 = 0) and (so mod 5 = 0) then

s:=s+so;

End;

Write('Tong la ',s);

Readln;

End.

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[1000],t,dem,t1;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) 

if (a[i]%2==0) cout<<a[i]<<" ";

cout<<endl;

t=0;

dem=0;

for (i=1; i<=n; i++)

if (a[i]%2==0)

{

t=t+a[i];

dem++;

}

cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0)<<endl;

t1=0;

for (i=1; i<=n; i++)

if (a[i]%2!=0 || a[i]%3==0) t1+=a[i];

cout<<t1;

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.

uses crt;

var a:array[1..250]of integer;

i,n,tam,j: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-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(a[i]:4);

readln;

end.