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;

long long n,i,nn,t1,t2,dem1,dem2,a[1000];

int main()

{

cin>>n;

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

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn<<endl;

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

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

cout<<endl;

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

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

cout<<endl;

t1=0;

t2=0;

dem1=0;

dem2=0;

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

{

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

{

t1+=a[i];

dem1++;

}

else 

{

t2+=a[i];

dem2++;

}

}

cout<<t1<<" "<<dem1<<endl;

cout<<t2<<" "<<dem2;

return 0;

}

20 tháng 2 2022

tham khảo

 

#include <bits/stdc++.h>

using namespace std;

long long n,i,nn,t1,t2,dem1,dem2,a[1000];

int main()

{

cin>>n;

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

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn<<endl;

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

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

cout<<endl;

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

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

cout<<endl;

t1=0;

t2=0;

dem1=0;

dem2=0;

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

{

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

{

t1+=a[i];

dem1++;

}

else 

{

t2+=a[i];

dem2++;

}

}

cout<<t1<<" "<<dem1<<endl;

cout<<t2<<" "<<dem2;

return 0;

}

uses crt;

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

i,n,min,t1,t2,dem1,dem2:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

min:=a[1];

for i:=1 to n do if min>a[i] then min:=a[i];

writeln(min);

writeln('Cac so chan la: ');

for i:=1 to n do 

if a[i] mod 2=0 then write(a[i]:4);

writeln;

writeln('Cac so le la: ');

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

writeln;

t1:=0;

t2:=0;

for i:=1 to n do 

begin

if a[i] mod 2=0 then t1:=t1+a[i]

else t2:=t2+a[i];

end;

writeln(t1,' ',t2);

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then dem1:=dem1+1

else dem2:=dem2+1;

end;

writeln(dem1,' ',dem2);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

int B[100],n,t;

{

cin>>n;

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

t=0;

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

if (B[i]%10==0) t+=B[i];

cout<<t<<endl;

int dem=0;

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

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

cout<<dem<<endl;

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

if ((A[i]%2!=0) && (A[i]%3==0)) cout<<A[i];

}

16 tháng 4 2023

program BaiToanMang;

var
  A: array[1..100] of integer;
  N, i, demChan, tongLeChia3: integer;

begin
  write('Nhap so phan tu cua mang: ');
  readln(N);
  writeln('Nhap cac phan tu cua mang: ');
  for i := 1 to N do
  begin
    write('a[', i, ']= ');
    readln(A[i]);
  end;
  tongLeChia3 := 0;
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 1) and (A[i] mod 3 = 0) then
    begin
      tongLeChia3 := tongLeChia3 + A[i];
    end;
  end;
  writeln('Tong cac so le chia het cho 3: ', tongLeChia3);
  demChan := 0;
  for i := 2 to N do
  begin
    if (A[i] mod 2 = 0) and (i mod 2 = 1) then
    begin
      demChan := demChan + 1;
    end;
  end;
  writeln('So phan tu chan o vi tri le: ', demChan);
  writeln('Cac so chan chia het cho 5: ');
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 0) and (A[i] mod 5 = 0) then
    begin
      write(A[i], ' ');
    end;
  end;
end.

ko bt đúng ko ko dùng pascal nhiều

16 tháng 4 2023

b dùng pascal hay python V:

Bài 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 

  if a[i] mod 2<>0 then write(a[i]:4);

readln;

end.

Bài 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.

uses crt;

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

i,n,dem,max,t,min,dem1:integer;

begin

clrscr;

write('n='); readln(n);

for i:=1 to n do 

 begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

max:=-32000;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then 

begin

dem:=dem+1;

if max<a[i] then max:=a[i];

end;

if dem=0 then writeln('Trong day khong co so chan')

else begin

writeln('So so chan la: ',dem);

writeln('So chan lon nhat la: ',max);

end;

t:=0;

for i:=1 to n do 

  if i mod 2=1 then t:=t+a[i];

writeln('Tong cac so o vi tri le la: ',t);

min:=maxint;

dem1:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then

begin  

inc(dem1);

if min>a[i] then min:=a[i];

end;

if dem1=0 then writeln('Trong day khong co so le')

else writeln('So le nho nhat la: ',min);

readln;

end. 

1:

#include <bits/stdc++.h>

using namespace std;

long long n=10, a[10],i,nn;

int main()

{

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

nn=a[1];

for (i=2; i<=n; i++) nn=min(nn,a[i]);

cout<<nn;

return 0;

}