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.

uses crt;

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

i,n,t,ln,nn:integer;

begin

clrscr;

readln(n);

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

ln:=a[1];

nn:=a[1];

t:=0;

for i:=1 to n do 

begin

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

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

t:=t+a[i];

end;

writeln(ln);

writeln(nn);

writeln(t);

for i:=1 to n do 

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

readln;

end.

25 tháng 5 2022

var n,i,max,min,s: integer;

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

begin

readln(n);

for i:=1 to n do begin

readln(a[i]);

s:=s+a[i];

end;

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

for i:=2 to n do begin

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

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

end;

writeln('MAX=',max,'  | MIN=',min);

for i:=1 to n do if a[i] mod 2=0 then write(a[i],' '); writeln;

write('Tong = ',s);

readln

end.

27 tháng 5 2022

var a:[array] of integer;

i,n,max,min,s:integer;

begin

write('Nhap so luong so 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];

s:=0;

for i:=1 to n do

begin

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

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

s:=s+a[i];

end;

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

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

writeln('Tong cac phan tu trong day la ',s);

writeln('Cac so chia het cho 2 la: ');

for i:=1 to n do

if a[i] mod 2 = 0 then write(a[i],'      ');

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.

11 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.

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

t=0;

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

ln=a[1];

nn=a[1];

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

{

ln=max(ln,a[i]);

nn=min(nn,a[i]);

}

cout<<t<<endl;

cout<<ln<<" "<<nn;

return 0;

}

12 tháng 5 2022

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

i,n,s,max,min:integer;

Begin

Write('Nhap so luong phan tu n = ');readln(n);

For i:=1 to n do

Begin

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

End;

s:=a[1];

max:=a[1];

min:=a[1];

For i:=2 to n do

Begin

s:=s+a[i];

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

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

End;

Writeln('Tong la ',s);

Writeln('So lon nhat la ',max);

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

Readln;

End.

Bai 2:

uses crt;

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

i,n,t,nn:integer;

begin

clrscr;

readln(n);

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

nn:=a[1];

for i:=1 to n do

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

write(nn);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,ln,nn,vt1,vt2;

int main()

{

cin>>n;

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

ln=a[1];

nn=a[1];

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

{

ln=max(ln,a[i]);

nn=min(nn,a[i]);

}

cout<<ln<<" "<<nn;

return 0;

}

19 tháng 1 2022

Var n,i,vtl,vtn,so max,min:integer;

Begin

Write('Nhap so luong so = ');readln(n);

vtl:=0;

vtn:=0;

max:=-32768;

min:=32767;

For i:=1 to n do

Begin

Write('Nhap vao so thu ',i);readln(so);

If so > max then

Begin

Max:=so;

vtl:=i;

End;

If so < min then

Begin

Min:=so;

vtn:=i;

End;

Writeln('So lon nhat la ',max,' tai vi tri thu ',i);

Write('So nho nhat la ',min,' tai vi tri thu ',i);

Readln;

End.

uses crt;

const fi='ketqua.out';

var f1:text;

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

i,n,min:integer;

begin

clrscr;

assign(f1,fi); rewrite(f1);

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(f1,min);

close(f1);

readln;

end.

uses crt;

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

i,n,t,ln,nn:integer;

begin

clrscr;

readln(n);

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

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(t);

ln:=a[1];

nn:=a[1];

for i:=1 to n do 

begin

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

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

end;

writeln(ln);

writeln(nn);

readln;

end.