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.

26 tháng 3 2022

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

begin
    clrscr;
    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:=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 trong mang la: ',max);
    write('So nho nhat trong mang la: ',min);
    readln
end.

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

for (i=1; i<=n; i++) if (a[i]%2!=0) cout<<i<<" ";

cout<<endl;

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn<<endl;

for (i=1; i<=n; i++) if (nn==a[i]) cout<<i<<" ";

return 0;

}

15 tháng 2 2022

sao không chạy được :<<

 

20 tháng 4 2023

Uses crt;

var n,i,max,min: integer;

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

begin clrscr;

readln(n);

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

max:=a[1];

for i:=1 to n do if(max<a[i]) then max:=a[i];

writeln(max);

min:=a[1];

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

writeln(min);

readln;

end.

uses crt;

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

i,n,max,dem: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 

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

write('Vi tri cua so lon nhat la: ');

for i:=1 to n do 

  if max=a[i] then write(i:4);

writeln;

dem:=0;

for i:=1 to n do 

  if max=a[i] then inc(dem);

writeln('So luong phan tu lon nhat trong day la: ',dem);

readln;

end. 

7 tháng 6 2021

uses crt;
var a:array[1..100000000] of int64;
      n,i,d,max:longint;
begin
        clrscr;
        repeat
                write('Nhap so luong phan tu: '); readln(n);
                if (n<=0) and (n>688886) then writeln('NHAP LAI!');
        until (n>0) and (n<=688886);
        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],' ');
        max:=a[1];
        for i:=1 to n do if a[i]>max then max:=a[i];
        writeln;
        writeln('So lon nhat: ',max);
        write('Vi tri cua cac so lon nhat: ');
        for i:=1 to n do if a[i]=max then begin write(i,' '); inc(d) end;
        writeln;
        writeln('So luong so lon nhat: ',d);
        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.

9 tháng 5 2023

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

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

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;

Write('Cac so vua nhap la ');

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

Writeln;

Writeln('Tong la ',s:10:2);

Writeln('So nho nhat la ',min:10:2);

Write('So lon nhat la ',max:10:2);

Readln

End.

27 tháng 5 2023

var
  Mang: array[1..100] of Integer;
  N, i, Tong, Min, Max: Integer;

begin
  // Yêu cầu nhập độ dài của dãy số từ bàn phím
  Write('Nhap do dai cua day so: ');
  ReadLn(N);

  // Yêu cầu nhập các phần tử của dãy từ bàn phím
  for i := 1 to N do
  begin
    Write('Nhap phan tu thu ', i, ': ');
    ReadLn(Mang[i]);
  end;

  // In ra màn hình các số vừa nhập
  Write('Cac so vua nhap: ');
  for i := 1 to N do
  begin
    Write(Mang[i], ' ');
  end;
  WriteLn;

  // Tính tổng các phần tử của dãy số
  Tong := 0;
  for i := 1 to N do
  begin
    Tong := Tong + Mang[i];
  end;
  WriteLn('Tong cac phan tu cua day so la: ', Tong);

  // Tìm giá trị nhỏ nhất của dãy số
  Min := Mang[1];
  for i := 2 to N do
  begin
    if Mang[i] < Min then
      Min := Mang[i];
  end;
  WriteLn('Gia tri nho nhat cua day so la: ', Min);

  // Tìm giá trị lớn nhất của dãy số
  Max := Mang[1];
  for i := 2 to N do
  begin
    if Mang[i] > Max then
      Max := Mang[i];
  end;
  WriteLn('Gia tri lon nhat cua day so la: ', Max);

  ReadLn;
end.

uses crt;

var a:array[1..200]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;

max:=a[1];

for i:=1 to n do 

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

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

write('Vi tri la: ');

for i:=1 to n do 

  if max=a[i] then write(i:4);

readln;

end.

20 tháng 12 2020

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.

20 tháng 12 2020

28 tháng 4 2023

Bài 23

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

i,n:integer;

s,tbc:real;

begin

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

for i:=1 to n do

begin

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

s:=s+a[i];

end;

tbc:=s/n;

writeln('Gia tri trung binh la ',tbc:10:2);

write('Cac so lon hon gia tri trung binh la: ');

for i:=1 to n do

if a[i] > tbc then write(a[i]:8);

readln

end.

28 tháng 4 2023

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

i,n,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];

for i:=2 to n do

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

for i:=1 to n do

begin

if max=a[i] then write(max,' o vi tri thu ',i);

break;

readln

end.