Những câu hỏi liên quan
Phạm Minh Châu
Xem chi tiết
Minh Lệ
11 tháng 5 2023 lúc 9:35

Program HOC24;

var i,n: integer;

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

function nt(x: integer): boolean;

var j: integer;

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;

begin

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 nt(a[i]) then write(a[i],' ');

readln

end.

Bình luận (0)
Nguyễn Thị Tươi
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 1 2022 lúc 9:18

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,x;

int main()

{

cin>>n;

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

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

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

{

int x=sqrt(a[i]);

if (x*x==a[i]) 

{

cout<<x;

return 0;

}

}

cout<<"Ko co so chinh phuong trong day";

return 0;

}

Bình luận (1)
ttanjjiro kamado
21 tháng 1 2022 lúc 9:18

uses crt;
var x,i,max,n,dem,dem1,dem2,dem3,t,t1:integer;
a,b,c,d,e:array[-32000..32000]of integer;
tbca,tbcd:real;
begin
clrscr;
write(‘n=’); readln(n);
for i:=1 to n do
begin
write(‘a[‘,i,’]=’); readln(a[i]);
inc(b[a[i]]);
end;
{———————————-cau-a—————————-}
max:=0;
for i:=1 to n do
if max<b[a[i]] then
begin
max:=b[a[i]];
x:=a[i];
end;
writeln(‘phan tu co so lan xuat hien nhieu nhat trong mang la: ‘,x);
{——————————–cau-b——————————-}
dem:=0;
for i:=1 to n do
if a[i]>=0 then
begin
dem:=dem+1;
c[dem]:=a[i];
end;
dem1:=0;
for i:=1 to dem do
if trunc(sqrt(c[i]))=sqrt(c[i]) then inc(dem1);
writeln(‘so luong so chinh phuong trong day la: ‘,dem1);
{——————————–cau-c—————————–}
dem2:=0;
dem3:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
inc(dem2);
d[dem2]:=a[i];
end;
if a[i]<0 then
begin
inc(dem3);
e[dem3]:=a[i];
end;
end;
t:=0;
t1:=0;
for i:=1 to dem2 do
t:=t+d[i];
tbcd:=t/dem2;
for i:=1 to dem3 do
t1:=t1+e[i];
tbca:=t1/dem3;
writeln(‘trung binh cong cac so am la: ‘,tbca:4:2);
writeln(‘trung binh cong cac so duong la: ‘,tbcd:4:2);
readln;
end.

Bình luận (0)
Trung Kien
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 3 2021 lúc 21:42

2: 

uses crt;

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

n,i: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]<0 then write(i:4);

readln;

end.

Bình luận (2)
Nguyễn Phương
24 tháng 3 2021 lúc 23:42

sao bài này giống bài tập cô mình giao thế nhỉ:>

 

Bình luận (0)
Lâm Thảo Như
5 tháng 5 2021 lúc 19:14

var max,min,n,i: integer;

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

begin

write('nhap so phan tu: ');readln(n);

for i:=1 to n do

begin

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

end;

max:=a[1];min:=a[1];

for i:=1 to n do

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

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

write('so lon nhat trong day la: ',max);writeln;

write('so nho nhat trong day la: ',min);writeln;

readln;

end.

Bình luận (0)
Hoàng Thùy
Xem chi tiết
Kiều Vũ Linh
13 tháng 3 2023 lúc 7:35

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.

Bình luận (0)
Phạm Thị Kim Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 4 2022 lúc 17:09

uses crt;

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

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

begin

clrscr;

readln(n);

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

t:=0;

for i:=1 to n do 

if a[i] mod 2<>0 then t:=t+a[i];

writeln(t);

for i:=1 to n do 

  if trunc(sqrt(a[i]))=sqrt(a[i]) then write(a[i]:4);

writeln;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

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

end;

readln;

end.

Bình luận (0)
Trang
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 5 2022 lúc 23:13

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

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

cout<<endl;

t=0;

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

cout<<t;

return 0;

}

Bình luận (0)
Mai Phương Lê
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

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ình luận (0)
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

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.

Bình luận (0)
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

Bài 3: 

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 

  if a[i] mod 2<>0 then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
Trương Hoàng Anh
Xem chi tiết
Trần Diệu Linh
11 tháng 6 2020 lúc 0:38

Bình luận (0)
Duy Anh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 4 2021 lúc 21:55

uses crt;

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

i,n,d,j,kt:integer;

st:string;

begin

clrscr;

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

for i:=1 to n do 

 begin

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

end;

for i:=1 to n do 

  begin

str(a[i],st);

d:=length(st);

kt:=0;

for j:=1 to d do

if st[j]<>st[d-j+1] then kt:=1;

if kt=0 then write(st:4);

end;

readln;

end.

Bình luận (0)