Những câu hỏi liên quan
my trần
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 8 2021 lúc 19:15

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. 

Bình luận (0)
Thi Đua Khen Thưởng
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 3 2021 lúc 19:18

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. 

Bình luận (0)
Master
Xem chi tiết
TÌNH ĐIÊN DẠI
Xem chi tiết
Vương Thị Minh Tâm
Xem chi tiết
vũ minh nhật
1 tháng 1 2022 lúc 12:23

a

Bình luận (0)
Nguyễn Lê Phước Thịnh
1 tháng 1 2022 lúc 14:04

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n;

int main()

{

cin>>n;

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

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

return 0;

}

Bình luận (0)
Phương Vũ Hà
Xem chi tiết
Nguyễn Lê Phước Thịnh
1 tháng 3 2021 lúc 17:19

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. 

Bình luận (0)
Linh Chii
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 5 2021 lúc 17:04

1:

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;

max:=a[1];

for i:=1 to n do 

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

writeln(max);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
13 tháng 5 2021 lúc 17:04

2:

uses crt;

var s:real;

i:integer;

begin

clrscr;

s:=0;

for i:=1 to 100 do 

  s:=s+1/i;

writeln(s:4:2);

readln;

end.

Bình luận (0)
HSNK HSG
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 10 2021 lúc 0:01

uses crt;

var a:array[1..50]of int64;

i,n,t,max,min:int64;

begin

clrscr;

readln(n);

for i:=1 to n do 

  readln(a[i]);

max:=a[1];

min:=a[1];

t:=0;

for i:=1 to n do 

begin

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

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

t:=t+a[i];

end;

writeln('Tong la: ',t);

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

write('Vi tri la: ');

for i:=1 to n do

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

writeln;

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

write('Vi tri la: ');

for i:=1 to n do 

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

readln;

end.

Bình luận (0)
Phan uyển nhi
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2022 lúc 9:53

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

}

Bình luận (0)