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,k,max,min,t,tam,j,dem:integer;
begin
clrscr;
{----------------------------------cau-a--------------------------------}
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('nhap k='); readln(k);
{----------------------------------cau-b--------------------------------}
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('gia tri lon nhat cua mang la: ',max);
writeln('vi tri cua no trong day la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
{----------------------------------cau-c--------------------------------}
writeln;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('gia tri nho nhat cua mang la: ',min);
writeln('vi tri cua no trong day la: ');
for i:=1 to n do
if min=a[i] then write(i:4);
{----------------------------------cau-d--------------------------------}
writeln;
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+sqr(a[i]);
writeln('tong binh phuong cac phan tu o vi tri chan la: ',t);
{----------------------------------cau-e--------------------------------}
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('mang duoc xep theo thu tu tang dan la: ');
for i:=1 to n do
write(a[i]:4);
{----------------------------------cau-f--------------------------------}
writeln;
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
writeln('trong mang co ',dem,' gia tri bang ',k);
readln;
end.

uses crt;

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

n,i,k,max,min,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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

max:=a[1];

for i:=1 to n do 

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

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

writeln('Vi tri la: ');

for i:=1 to n do 

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

writeln;

min:=a[1];

for i:=1 to n do

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

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

writeln('Vi tri la: ');

for i:=1 to n do

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

writeln;

t:=0;

for i:=1 to n do 

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

writeln('Tong binh phuong cac gia tri o vi tri chan la: ',t);

readln;

end. 

30 tháng 12 2020

uses crt;

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

writeln('Vi tri cua no trong mang la: ');

for i:=1 to n do 

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

readln;

end.

uses crt;

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

i,n,dem,max,t,min,dem1:integer;

begin

clrscr;

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

for i:=1 to n do 

 begin

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

end;

dem:=0;

max:=-32000;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then 

begin

dem:=dem+1;

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

end;

if dem=0 then writeln('Trong day khong co so chan')

else begin

writeln('So so chan la: ',dem);

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

end;

t:=0;

for i:=1 to n do 

  if i mod 2=1 then t:=t+a[i];

writeln('Tong cac so o vi tri le la: ',t);

min:=maxint;

dem1:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then

begin  

inc(dem1);

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

end;

if dem1=0 then writeln('Trong day khong co so le')

else writeln('So le nho nhat la: ',min);

readln;

end. 

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.

#include <bits/stdc++.h>

using namespace std;

long long a[40],i,n,ln;

int main()

{

cin>>n;

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

{

cin>>a[i];

}

ln=a[1];

for (i=1; i<=n; i++) ln=max(ln,a[i]);

for (i=n; i>=1; i--)

if (ln==a[i]) 

{

cout<<i;

break;

}

return 0;

}

uses crt;

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

i,n,t,min,vt: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 3=0 then t:=t+a[i];

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

min:=a[1];

for i:=1 to n do 

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

vt:=1;

for i:=1 to n do 

  if min=a[i] then 

begin

if vt<i then vt:=i;

end;

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

writeln('Vi tri la: ',vt);

readln;

end. 

#include <bits/stdc++.h>

using namespace std;

long long a[150],i,s,n,nn;

int main()

{

cin>>n;

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

s=1;

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

if (a[i] %2!=0 && a[i]%3==0) s=s*a[i];

cout<<s<<endl;

nn=a[1];

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

for (i=n; i>=1; i--) 

if (nn==a[i]) 

{

cout<<i<<endl;

break;

}

sort(a+1,a+n+1);

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

return 0;

}

#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];

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;

}

2 tháng 5 2022

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

i,n,d,max:integer;

Begin

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

For i:=1 to n do

Begin

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

End;

max:=a[1];

For i:=2 to n do

Begin

If a[i] > max then

Begin

max:=a[i];

d:=i;

End;

End;

Write('Phan tu lon nhat la ',max,' o vi tri ',d);

Readln;

End.