Những câu hỏi liên quan
Nguyễn Thanh Anh
Xem chi tiết
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 1 2021 lúc 22:42

uses crt;

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

i,n,t,t1,t2,t3,min,max:integer;   

kt:boolean;

begin

clrscr;

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

for i:=1 to n do 

begin     

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

end;

writeln('Day so ban vua nhap la: ');

for i:=1 to n do 

write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

t:=t+a[i];

kt:=true;

for i:=2 to trunc(sqrt(t)) do 

if t mod i=0 then     

begin       

kt:=false;       

break;     

end;

writeln('Tong cua day so la: ',t);

if (kt=true) and (t>1) then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

writeln('Cac so o vi tri le cua day so la: ');

t1:=0;

for i:=1 to n do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri le cua day so la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac so o vi tri chan cua day so la: ');

t2:=0;

for i:=1 to n do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri chan cua day so la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if t3=t2 then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to n do 

begin     

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

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

end;

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

writeln('So nho nhat cua day la: ',min);

writeln('Tong cua so lon nhat va so nho nhat la: ',max+min);

readln;

end.

Bình luận (0)
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 1 2021 lúc 20:43

uses crt;

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

n,i,t,kt,j,t1,t2,t3,max,min:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

writeln('Day so ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln('Tong cua day so vua nhap la: ',t);

kt:=0;

for i:=2 to trunc(sqrt(t)) do 

  if t mod i=0 then

begin

kt:=1;

break;

end;

if (kt=0) and (t>1) then writeln(t,' la so nguyen to');

else writeln(t,' khong la so nguyen to');

t1:=0;

writeln('Cac so o vi tri le cua day la: ');

for i:=1 to n do 

  if i mod 2=1 then 

begin

write(a[i]:4);

t1:=t1+a[i];

end;

writeln;

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

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

t2:=0;

writeln('Cac so o vi tri chan la: ');

for i:=1 to n do 

  if i mod 2=0 then 

begin

write(a[i]:4);

t2:=t2+a[i];

end;

writeln;

writeln('Tong cac so o vi tri chan la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if t3=t2 then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to n do 

begin

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

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

end;

writeln('Gia tri lon nhat la: ',max);

writeln('Gia tri nho nhat la: ',min);

writeln('Tong cua hai so lon nhat va nho nhat la: ',max+min);

readln;

end.

Bình luận (1)
Thiên Phúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 12 2020 lúc 20:00

uses crt;

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

begin

clrscr;

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

writeln('Cac so nguyen to trong khoang tu 2 toi ',n,' la: ');

for i:=2 to n do 

  begin

kt:=0;

for j:=2 to i-1 do 

  if i mod j=0 then kt:=1;

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

end;

writeln;

writeln('Cac so chinh phuong trong khoang tu 0 toi ',n,' la: ');

for i:=0 to n do 

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

writeln;

writeln('Cac so hoan hao trong khoang tu 1 toi ',n,' la: ');

for i:=1 to n do 

  begin

t:=0;

for j:=1 to i-1 do 

  if i mod j=0 then t:=t+j;

if t=i then write(i:4);

end;

readln;

end.

Bình luận (0)
huỳnh duy cát
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 3 2021 lúc 19:53

a)

uses crt;

var i,n:integer;

begin

clrscr;

repeat

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

until n<100;

if n mod 2=0 then 

begin

for i:=0 to n do 

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

end

else writeln(n,' khong la so chan');

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
20 tháng 3 2021 lúc 19:53

b)

uses crt;

var i,n:integer;

begin

clrscr;

repeat

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

until n<100;

if n mod 2=1 then 

begin

for i:=1 to n do 

  if i mod 2=1 then write(i:4);

end

else writeln(n,' khong la so le');

readln;

end.

Bình luận (0)
crazy
Xem chi tiết

Program HOC24;

var i,d,j,n integer;

begin

readln(n);

for i:=2 to n do

begin

d:=0;

for j:=1 to i do

if i mod j =0 then d=d+1;

if d=2 then write(i,' ');

end;

readln

end.

Bình luận (0)
Đặng Tiến Đức
Xem chi tiết
Lee Hà
9 tháng 12 2021 lúc 10:16

program Chanle;

uses crt;

var x: integer;

begin

clrscr;

readln(x)

if (x mod 2 = 0) then write('day la so chan') else write('day la so le');

readln

end.

Bình luận (0)
Thiên Phúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 12 2020 lúc 12:22

uses crt;

var n,i:integer;

begin

clrscr;

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

for i:=1 to n do 

  if (i mod 2=0) and (i mod 5=0) then write(i:4);

readln;

end. 

Bình luận (0)
Bùi Anh Tuấn
20 tháng 12 2020 lúc 20:04

Bình luận (0)
Bùi Anh Tuấn
20 tháng 12 2020 lúc 20:06

cách này cũng đúng nhá

Bình luận (0)
khánh băng
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2023 lúc 22:35

uses crt;

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

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

begin

clrscr;

readln(n);

for i:=1 to n do write(i:4);

writeln;

for i:=2 to n do

begin

kt:=0;

for j:=2 to i-1 do 

if i mod j=0 then kt:=1;

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

end;

readln;

end.

Bình luận (0)