Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Phùng Phúc An
Xem chi tiết
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;

}

NGUYỄN HOÀNG DŨNG
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 10 2021 lúc 0:47

a:

#include <bits/stdc++.h>

using namespace std;

long long n,x,i,ln;

int main()

{

cin>>n>>x;

ln=x;

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

{

cin>>x;

ln=max(ln,x);

}

cout<<ln;

return 0;

}

Lee Jihoon
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 2 2021 lúc 20:31

uses crt;

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

i,n,dem,max:integer;

begin

clrscr;

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

for i:=1 to n do 

begin     

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

end;

dem:=0;

max:=a[1];

for i:=1 to n do 

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

for i:=1 to n do 

if max=a[i] then     

begin       

inc(dem);       

b[dem]:=a[i];       

c[dem]:=i;     

end;

if dem=1 then writeln('So lon nhat la: ',b[dem],' vi tri la: ',c[dem])

else writeln('So lon nhat la: ',b[1],' vi tri la: ',c[1]);

readln;

end.

Nguyễn Thị Xuân Hiền
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 12 2020 lúc 12:01

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.

Dương
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 10 2021 lúc 23:30

a: 

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

t=t+x;

}

cout<<t;

return 0;
}

Hoàng Thị Minh Nguyệt
Xem chi tiết
Giàu Nguyễn
Xem chi tiết
nguyễn an phát
4 tháng 4 2021 lúc 18:01

program tim_so_nguyen_am;

uses crt;

var n,i:integer;

b:array[1..1000]of integer;

begin

clrscr;

write('nhap so phan tu :');readln(n);

repeat

for i:=1 to n do

begin

write('nhap phan tu b[',i,']:');readln(b[i]);

end;

if abs(a[i]>1000)then write('ban hay nhap lai:');

until abs(b[i]<=1000);

writeln('cac phan tu nguyen duong cua mang la:');

for i:=1 to n do

if b[i]>=0 then write(b[i]:5);

writeln;

writeln('cac phan tu nguyen am cua mang la:');

readln;

end.

for i:=1 to n do

if b[i]<0 then write(b[i]:5);

Nguyễn Lê Phước Thịnh
4 tháng 4 2021 lúc 19:50

uses crt;

var b:array[1..25]of integer;

i,n,dem1,dem2:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

write('B[',i,']='); readln(b[i]);

end;

dem1:=0;

dem2:=0;

for i:=1 to n do

 begin

if b[i]>0 then inc(dem1);

if b[i]<0 then inc(dem2);

end;

writeln('So cac so nguyen duong la: ',dem1);

writeln('So cac so nguyen am la: ',dem2);

readln;

end.

Nguyễn Xuân Khánh
Xem chi tiết
Nguyễn Xuân Khánh
10 tháng 12 2021 lúc 11:14

giúp em với ạ

Nguyễn Lê Phước Thịnh
10 tháng 12 2021 lúc 23:14

#include <bits/stdc++.h>

using namespace std;

long long a[10000],n,i,ln,vt;

int main()

{

cin>>n;

ln=LLONG_MIN;

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

{

cin>>a[i];

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

}

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

if (ln==a[i]) vt=i;

swap(a[1],a[vt]);

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

cout<<a[i]<<" ";

return 0;

}