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.

1:

uses crt;

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

i,n,j,m,max,min:integer;

begin

clrscr;

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

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

for i:=1 to n do 

for j:=1 to m do 

begin

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

end;

for i:=1 to n do 

begin

for j:=1 to m do 

  write(a[i,j]:4);

writeln;

end;

max:=a[1];

min:=a[1];

for i:=1 to n do 

  for j:=1 to m do 

begin

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

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

end;

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

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

readln;

end.

uses crt;

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

i,n,dem1,dem2:integer;

begin

clrscr;

readln(n);

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

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

writeln;

dem1:=0;

for i:=1 to n do 

  if (a[i]>a[i-1]) and (a[i]>a[i+1]) then dem1:=dem1+1;

dem2:=0;

for i:=1 to n do 

  if (a[i]<a[i-1]) and (a[i]<a[i+1]) then dem2:=dem2+1;

writeln(dem1);

writeln(dem2);

readln;

end.

uses crt;

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

n,i,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.

uses crt;
var a,b,c,d:array[1..100]of integer;
n,i,dem,t,max,min,j,dem1,kt,dem2,dem3,kt1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Phan tu dau tien la: ',a[1]);
writeln('Phan tu cuoi cung la: ',a[n]);
dem:=0;
for i:=1 to n do
if a[i] mod 4=0 then inc(dem);
writeln('So luong phan tu chia het cho 4 la: ',dem);
t:=0;
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>10) then t:=t+a[i];
writeln('Tong cac so chan va lon hon 10 la: ',t);
dem1:=0;
for i:=1 to n do
if sqrt(a[i])=trunc(sqrt(a[i])) then
begin
inc(dem1);
b[dem1]:=a[i];
end;
writeln;
writeln('So luong so chinh phuong trong mang la: ',dem1);
if dem1>0 then
begin
writeln('Cac so chinh phuong co trong mang la: ');
for i:=1 to dem1 do
write(b[dem1]:4);
end;
writeln;
kt:=0;
for i:=1 to n do
if a[i] mod 2<>0 then kt:=1;
if kt=0 then writeln('Day la mang chan')
else writeln('Day khong la mang chan');
readln;
end.

22 tháng 4 2020

Câu 2:

Program hotrotinhoc_hoc24;

var i,n,min: integer;

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

begin

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

for i:=1 to n do

begin

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

end;

min:=32000;

for i:=1 to n do

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

write('Chi so cua gia tri nho nhat la :');

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

writeln;

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

readln

end.

22 tháng 4 2020

Câu 1:

Program hotrotinhoc_hoc24;

var i,n,k,t: integer;

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

begin

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

t:=0;

for i:=1 to n do

begin

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

end;

write('Nhap so nguyen k : '); readln(k);

for i:=1 to n do

if a[i] mod k=0 then t:=t+a[i];

write('Tong gia tri cac phan tu cua mang la boi cua so nguyen K la:',t);

readln

end.

const fi='bt.inp';
fo='bt.out';
var f1,f2:text;
a:array[1..100]of integer;
i,n,max,min:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
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;
for i:=1 to n do
if (min<a[i]) and (a[i]<max) then write(f2,a[i]:4);
close(f1);
close(f2);
end.

Câu 1:

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

Câu 2: 

uses crt;

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

i:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

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

end;

for i:=1 to 10 do 

 write(a[i]:4);

readln;

end.

Câu 3: 

uses crt;

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

i,n,t:integer;

begin

clrscr;

repeat

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

until (0<n) and (n<=15);

for i:=1 to n do 

begin

repeat

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

until a[i]<=100;

end;

writeln('Mang da nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do

if a[i] mod 3=0 then t:=t+a[i];

writeln('Tong cac phan tu chia het cho 3 la: ',t);

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

for i:=1 to n do 

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

readln;

end.

18 tháng 10 2020

uses crt;
var a:array[1..100]of integer;
n,i,t,dem,max,min,kt,j,x,dem1,k: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('Tong cac phan tu cua mang la: ',t);
dem:=0;
for i:=1 to n do
if a[i]<0 then inc(dem);
writeln('So phan tu am co trong mang la: ',dem);
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 phan tu nho nhat va lon nhat trong mang la: ',max+min);
writeln('Vi tri cac so nguyen to co trong mang la: ');
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 write(i:4);
end;
writeln;
repeat
write('Nhap x='); readln(x);
until x>0;
dem1:=0;
for i:=1 to n do
if a[i]>0 then inc(dem1);
if dem1<x then writeln(x,' nho hon so luong so nguyen duong trong mang')
else if dem1=x then writeln(x,' la so luong so nguyen duong trong mang')
else writeln(x,' lon hon so luong so nguyen duong trong mang');
readln;
end.

8 tháng 9 2017

Đáp án đúng : D