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.

D
datcoder
CTVVIP
24 tháng 12 2023

Program HOC24;

var i,n,l,c: byte;

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

begin

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

for i:=1 to n do 

begin

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

end;

write('Day vua nhap la: ');

for i:=1 to n do write(a[i],' ');

writeln;

c:=0; l:=0;

for i:=1 to n do 

if a[i] mod 2=0 then c=c+1 else l=l+1;

writeln('Day co ',c,' so chan');

writeln('Day co ',l,' so le');

readln

end.

D
datcoder
CTVVIP
24 tháng 12 2023

Program HOC24;

var i,n: byte;

t: longint;

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

begin

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

for i:=1 to n do 

begin

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

end;

t:=0;

for i:=1 to n do 

if a[i]>10 then t:=t+a[i];

writeln('Tong cac so lon hon 10 la: ',t);

readln

end.

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.

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.

30 tháng 1 2021

cái dong đầu bị lỗi chỗ a[i] á xem lại hộ mình với

4 tháng 5 2021

uses crt;
var a: array[1..100] of integer;
i,n,s,s1,s2,s3: integer;
begin
clrscr;
writeln(' nhap so phan tu cua day'); readln(n);

for i:=1 to n do
begin
writeln('a[',i,']'); readln(a[i]);
end;
write('day vua nhap la:');
s:=0;
for i:=1 to n do
begin
write(a[i],' ');
s:=s+a[i];
if a[i] mod 2=0 then s1:=s1+a[i];
if a[i] mod 2<>0 then s2:=s2+a[i];
if a[i] mod 3=0 then s3:=s3+a[i];
end;
writeln;
writeln('tong bang:',s);
writeln('tong chan:',s1);
writeln('tong le:',s2);
writeln('tong chia het cho 3:',s3);
readln
end.

26 tháng 5 2021

program max_min;

uses crt;

var i,n:integer;

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

begin

clrscr;

write('nhap n:');readln(n);

for i:=1 to n do

begin

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

end;

writeln('day vua nhap la:');

for i:=1 to n do

write(a[i]:3);

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.

26 tháng 5 2021

program max_min;

uses crt;

var i,n,max,min:integer;

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

begin

clrscr;

write('nhap n:');readln(n);

for i:=1 to n do

begin

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

end;

writeln('day vua nhap la:');

for i:=1 to n do

write(a[i]:3);

writeln;

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

for i:=1 to n do

begin

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

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

end;

writeln('gia tri lon nhat: ',max,' gia tri nho nhat: ',min);

readln;

end.

7 tháng 6 2021

uses crt;
var a:array[1..1000000] of longint;
      n,i,max,min:longint;
begin
      clrscr;
      write('Nhap so luong phan tu: '); readln(n);
      for i:=1 to n do 
            begin
                  write('Nhap phan tu thu ',i,': '); readln(a[i]);
            end;
      write('Day so vua nhap: ');
      for i:=1 to n do write(a[i],' '); writeln;
      max:=a[1];min:=a[1];
      for i:=2 to n do 
            begin
                  if a[i]>max then max:=a[i];
                  if a[i]<min then min:=a[i];
            end;
      writeln('GTLN: ',max);
      writeln('GTNN: ',min);
      readln;
end.

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)

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.

10 tháng 4 2023

Uses crt;

var max,min,n,i,m,n: longint;

a: array[1..100] of longint

begin clrscr;

for i:=1 to n do begin

if(a[i] mod 2=0) then m:=m+a[i];

if(a[i] mod 2<>0) then n:=n+a[i];

end;

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('Tong cac phan tu chan: ',m);

Writeln('Tong cac phan tu le: ',n);

Writeln('Phan tu co gia tri lon nhat: ',max);

Writeln('Phan tu co gia tri nho nhat: ',min);

readln;

end.