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.

10 tháng 4 2021

Program HOC24;

var d,i,n: integer;

a: array[1..1000] of integer;

t: longint;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

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

for i:=1 to n do

begin

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

end;

d:=0; t:=0;

for i:=1 to n do

if nt(a[i]) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' so nguyen to trong day');

write('Tong cac so nguyen to trong day la: ',t);

readln

end.

uses crt;

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

i,n,dem,t,j,kt:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem:=0;

t:=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

begin

inc(dem);

t:=t+a[i];

end;

end;

writeln('So luong so nguyen to la: ',dem);

writeln('Tong cac so nguyen to la: ',t);

readln;

end.

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.

Câu 1: 

uses crt;

var a:array[1..100]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 

  t:=t+a[i];

writeln(t);

readln;

end.

Câu 2: 

uses crt;

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

i,n,x,dem,kt:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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

kt:=0;

dem:=0;

for i:=1 to n do 

if a[i]=x then 

begin

kt:=1;

write(i:4);

inc(dem);

end;

if kt=0 then writeln('Khong co ',x,' trong day');

writeln(x,' xuat hien ',dem,' lan trong day');

readln;

end.

Câu 1: 

uses crt;

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

i,n:integer;

t:real;

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 2=0 then t:=t+a[i];

writeln(t:4:2);

readln;

end.

Câu 2: 

uses crt;

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

i,n:integer;

t:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=1;

for i:=1 to n do 

  t:=t*a[i];

writeln(t:4:2);

readln;

end.

5 tháng 5 2023

a) var a:array[1..1000] of integer;

i,k:integer;

p:longint;

begin

write('k = ');readln(k);

p:=1;

for i:=1 to k do

begin

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

if a[i]<30 then p:=p*a[i];

end;

write('Tich la ',p);

readln

end.

b) 

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

i,k:integer;

s:longint;

begin

write('k = ');readln(k);

for i:=1 to k do

begin

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

if a[i]<100 then s:=s+a[i];

end;

write('Tong la ',s);

readln

end.

Bài 1: 

uses crt;

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

i,n,min:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

min:=a[1];

for i:=1 to n do 

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

writeln(min);

readln;

end.

Bài 2: 

uses crt;

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

i,n,max:integer;

begin

clrscr;

write('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.

Câu 1: 

#include <bits/stdc++.h>

using namespace std;

long long i,n,k,dem,x;

int main()

{

cin>>n;

cin>>k;

dem=0;

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

{

cin>>x;

if (x==k) dem++;

}

cout<<dem;

return 0;

}

5 tháng 5 2023

Bài 5:

Var a:array:[1..1000] of integer;

i,n,max:integer;

sc, sl:longint;

Begin

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

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');rreadlna[i]);

If a[i] mod 2 = 0 then sc:=sc+b[i];

If a[i] mod 2 <> 0 then sl:=sl+a[i];

End;

max:=a[1];

For i:=2 to n do

If a[i] > max then max:=a[i];

Writeln('Tong cac so chan la ',sc);

Writeln('Tong cac so le la ',sl);

write('So lon nhat la ',max);

Readln

End.

5 tháng 5 2023

Xin cảm ơnloading...  

20 tháng 4 2023

Var a:array[1..1000] of integer;

i,n:integer;

sc,sl:longint;

Begin

Write('Nhap so luong so cua day ');readln(n);

For i:=1 to n do

Begin

Write(a,'[',i,'] = ');readln(a[i]);

End;

Write('Tong cac so chan la ');

For i:=1 to n do

If a[i] mod 2 = 0 then sc:=sc+a[i];

Writeln(sc);

Write('Tong cac so le la ');

For i:=1 to n do

If a[i] mod 2 <> 0 then sl:=sl+a[i];

Write(sl);

Readln

End.

10 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long a[100],b[100],c[100],n,i,dem1,dem2;

int main()

{

cin>>n;

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

cin>>a[i];

dem1=0;

dem2=0;

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

{

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

{

dem1++;

b[dem1]=a[i];

}

else 

{

dem2=0;

c[dem2]=a[i];

}

}

sort(b+1,b+dem1+1);

sort(c+1,c+dem2+1);

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

cout<<b[i]<<" ";

for (i=dem2; i>=1; i--)

cout<<c[i]<<" ";

return 0;

}