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.

Bài 1:

uses crt;

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

i,n,max,min:integer;

begin

clrscr;

write('Nhap n='); 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

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);

readln;

end.

Bài 2:

uses crt;

var n,i,s:integer;

begin

clrscr;

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

s:=0;

for i:=1 to n do

s:=s+i;

writeln('Tong cua ',n,' so tu nhien dau tien la: ',s);

readln;

end.

Bài 3:

uses crt;

var n,t:integer;

begin

clrscr;

n:=0; t:=0;

while t<=1000 do

begin

inc(n);

t:=t+n;

end;

writeln('Tong cua n so tu nhieu dau tien sao cho tong nho nhat lon hon 1000 la: ',t);

writeln('So lan n nang len la: ',n);

readln;

end.

Bài 4:

uses crt;

var a,b:integer;

begin

clrscr;

write('a='); readln(a);

write('b='); readln(b);

if a<b then writeln(a,' ',b);

if a=b then writeln('hai so bang nhau');

if b<a then writeln(b,' ',a);

readln;

end.

Bài 5:

uses crt;

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

i,n,min:integer;

begin

clrscr;

write('Nhap 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('Gia tri nho nhat la: ',min);

readln;

end.

10 tháng 5 2021

uses crt;

var n, i, j, dem: longint; {Bạn có thể thay longint thành integer nha}

A:array[1..1000] of longint;

begin

clrscr;

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

for i:=1 to n do

begin

write('Nhap phan tu thu ',i,': ');

readln(A[i]);

end;

Write('Cac so nguyen to co trong mang la: ');

for i:=1 to n do

begin

dem:=0;

for j:=2 to A[i]/2 do

if A[i] mod j=0 then dem:=dem+1;

if dem=0 then write(A[i],'; ');

end;

end.

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.

7 tháng 5 2023

program TimMaxMinCuaMang;

var

      mang: array of integer;

      n, i, max, min: integer;

begin

      write('Nhap so phan tu cua mang: ');

      readln(n);

      setlength(mang, n);

      writeln('Nhap cac phan tu cua mang:');

      for i := 0 to n-1 do

      begin

            readln(mang[i]);

      end;

      max := mang[0];

      min := mang[0];

      for i := 1 to n-1 do

      begin

            if mang[i] > max then

                  max := mang[i];

            if mang[i] < min then

                  min := mang[i];

      end;

      writeln('Phan tu lon nhat la: ', max);

      writeln('Phan tu nho nhat la: ', min);

      readln;

end.

8 tháng 5 2023

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

i,n,min,max:integer;

Begin

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

For i:=1 to  n do

Begin

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

End;

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('So lon nhat la ',max);

write('So nho nhat la ',min);

Readln

End.

uses crt;

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

i,n:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

readln;

end.

12 tháng 4 2023

uses crt;
var n,i,max : integer;
a : array[1..100] of integer;
begin

   clrscr;
   write('Nhap so n :'); readln(n);
   for i:=1 to n do

     begin
        write('Nhap phan tu thu ',i,' la : '); readln(a[i]);
     end;
max:=a[1];
for i:=2 to n do if max<a[i] then max:=a[i];
write('So *** nhat trong mang la :', max);

min:=a[1];
for i:=2 to n do if min>a[i] then min:=a[i];
write('So nho nhat trong mang la :', min);
readln
end.

2 tháng 5 2023

Program HOC24;

var min,max,i,n: integer;

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

begin

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

for i:=1 to n do 

begin

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

end;

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('Gia tri lon nhat la: ',max); 

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

readln

end.

uses crt;

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

min,n,i:integer;

{----------------chuong-trinh-con-------------------}

function nn(x,y:integer):integer;

begin

if x<y then nn:=x

else nn:=y;

end;

{-----------------chuong-trinh-chinh-----------------}

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

min:=nn(a[1],a[2]);

for i:=3 to n do 

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

writeln(min);

readln;

end.

6 tháng 5 2021

1. uses crt;
var a,vt:array[1..100]of integer;
n,i,t,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>=0;
end;
t:=0;
for i:=1 to n do
begin
if t<100 then
begin
t:=t+a[i];
dem:=dem+1;
vt[dem]:=i;
end;
end;
writeln(vt[dem]);
readln;
end.

Câu 2: 

uses crt;

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

i,n,kt:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

kt:=0;

for i:=1 to n-1 do 

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

if kt=0 then writeln('Day la day so khong giam')

else writeln('Day khong la day so khong giam');

readln;

end.

12 tháng 5 2021

uses crt;

var n,i:integer;

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

begin

clrscr

write(‘nhap so phan tu cua day:’);readln(n);

for i:=1 to n do

begin

write(‘a[‘,i,’]=’);readln(a[i]);

end;

writeln(‘day so da nhap:’);

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

readln;

end.

uses crt;

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

i,n,max: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 vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

max:=a[1];

for i:=1 to n do 

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

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

readln;

end.

21 tháng 6 2020

program hello;

uses crt;

Var n,i,j,k: integer;

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

begin;

a[1]:=k;

Readln(n);

For i:=1 to n do

Begin;

Writeln('nhap a[',i,'] '); Readln(a[i]);

End;

For i:=1 to n-1 do

For j:=i+1 to n do

If a[i]<a[j] then k:=a[j];

Writeln('gia tri lon nhat la', k);

end.