Những câu hỏi liên quan
Lê Phương Thảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 21:55

uses crt;

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

i,n,dem,t,t1,t2,t3,t4:integer;

begin

clrscr;

repeat

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

until (0<n) and (n<=250);

for i:=1 to n do 

  begin

repeat

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

until (0<a[i]) and (a[i]<=500);

end;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=1 then inc(dem);

writeln('So phan tu co gia tri le la: ',dem);

t:=0;

for i:=1 to n do 

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

writeln('Tong cac phan tu co chi so chan la: ',t);

t1:=0;

for i:=1 to n do 

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

writeln('Tong cac phan tu co chi so le la: ',t1);

t2:=0;

for i:=1 to n do 

  if (i mod 2=0) and (a[i] mod 2=0) then t2:=t2+a[i];

writeln('Tong cac phan tu chan co chi so chan la: ',t2);

t3:=0;

for i:=1 to n do 

  if (i mod 2=1) and (a[i] mod 2=1) then t3:=t3+a[i];

writeln('Tong cac phan tu co chi so le la: ',t3);

t4:=0;

for i:=1 to n do 

  t4:=t4+a[i];

writeln('Trung binh cong cac so trong day la: ',t4/n:4:2);

readln;

end.

Bình luận (0)
Phạm anh vũ
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2022 lúc 22:31

#include <bits/stdc++.h>

using namespace std;

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

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

cout<<ln<<endl;

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

return 0;

}

Bình luận (0)
taf.amp
Xem chi tiết
Kiều Vũ Linh
2 tháng 5 2022 lúc 7:50

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.

Bình luận (0)
Anh Lê duy
Xem chi tiết
Anh Lê duy
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 12 2021 lúc 22:51

Bài 1: 

#include <bits/stdc++.h>

using namespace std;

long long a[250],i,n,k;

int main()

{

cin>>n>>k;

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

cin>>a[i];

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

if (a[i]==k) cout<<i<<" ";

return 0;

}

Bình luận (0)
Tran Trang
Xem chi tiết
HT.Phong (9A5)
20 tháng 4 2023 lúc 12:25

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.

Bình luận (0)
Trung Kien
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 3 2021 lúc 21:42

2: 

uses crt;

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

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

  if a[i]<0 then write(i:4);

readln;

end.

Bình luận (2)
Nguyễn Phương
24 tháng 3 2021 lúc 23:42

sao bài này giống bài tập cô mình giao thế nhỉ:>

 

Bình luận (0)
Lâm Thảo Như
5 tháng 5 2021 lúc 19:14

var max,min,n,i: integer;

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

begin

write('nhap so phan tu: ');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

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

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

write('so lon nhat trong day la: ',max);writeln;

write('so nho nhat trong day la: ',min);writeln;

readln;

end.

Bình luận (0)
taf.amp
Xem chi tiết
Kiều Vũ Linh
2 tháng 5 2022 lúc 7:52

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.

Bình luận (0)
nguyễn xuân hoàng tùng
Xem chi tiết