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.
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.
#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 n,i,x,dem1,dem2;
int main()
{
cin>>n;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2!=0) dem1++;
else dem2++;
}
cout<<dem1<<" "<<dem2;
return 0;
}
uses crt;
var a:array[1..100]of integer;
n,i,k,dem,dem1: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);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
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.
uses crt;
var a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]>10 then inc(dem);
writeln('So phan tu lon hon 10 la: ',dem);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
writeln('So luong so chan la: ',dem1);
writeln('So luong so le la: ',dem2);
t:=0;
s:=1;
for i:=1 to n do
begin
if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];
if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];
end;
writeln('Tong cac so o vi tri chan co gia tri le la: ',t);
writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
writeln('Cac so chan va lon hon 10 la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>10) then write(a[i]:4);
readln;
end.
#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;
}
C mk làm pascal à
câu lệnh giống nhau
thuật toán cứ chạy từ 1 đến n xét mỗi phần tử nếu a[i] mod 2 =0 thì lưu vào 1 mảng ngược lại lưu vàng mảng khác đến cuối gọi ra
#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;
}