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
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
Văn Công Sỹ
Xem chi tiết
Văn Công Sỹ
25 tháng 4 2021 lúc 10:28

Làm giúp bài này nhé

 

Bùi Anh Tuấn
25 tháng 4 2021 lúc 19:41

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

uses crt;

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

i,n,min,tam,j:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

min:=a[1];

for i:=1 to n do 

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

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

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;

for i:=1 to n do write(a[i]:4);

readln;

end.

Huy Phạm
Xem chi tiết
Kiều Vũ Linh
3 tháng 5 2023 lúc 6:12

1)

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

i,n,t:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

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

End;

For i:=1 to n do

If a[i] > a[i+1] then

Begin

t:=a[i];

a[i]:=a[i+1];

a[i+1]:=t;

End;

Write('Sap xep tang dan ');

For i:=1 to n do write(a[i]:8);

Readln

End.

Kiều Vũ Linh
3 tháng 5 2023 lúc 6:13

2)

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

i,n,t:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

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

End;

For i:=1 to n do

If a[i] < a[i+1] then

Begin

t:=a[i];

a[i]:=a[i+1];

a[i+1]:=t;

End;

Write('Sap xep giam dan ');

For i:=1 to n do write(a[i]:8);

Readln

End.

Thảo Nguyên 36-88
Xem chi tiết
JamesDang
26 tháng 3 2022 lúc 20:01

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.

Tuoi tom May
Xem chi tiết
Phía sau một cô gái
4 tháng 5 2023 lúc 20:40

program TimMinMaxTrungBinh;

var

      N, i, max, min, sum: integer;

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

      TB, minTB, maxTB: real;

begin

      writeln('Nhap so nguyen duong N:');

      readln(N);

      sum := 0;

      for i := 1 to N do

      begin

            write('Nhap so thu ', i, ': ');

            readln(a[i]);

            sum := sum + 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;

      TB := sum / N;

      minTB := TB;

      maxTB := TB;

      for i := 1 to N do

      begin

            if (a[i] < TB) and (a[i] < minTB) then

                  minTB := a[i];

            if (a[i] > TB) and (a[i] > maxTB) then

                  maxTB := a[i];

      end;

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

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

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

      if minTB = TB then

            writeln('Khong co gia tri nao nho hon TB')

      else

            writeln('Gia tri nho nhat < TB la: ', minTB);

      if maxTB = TB then

            writeln('Khong co gia tri nao lon hon TB')

      else

            writeln('Gia tri lon nhat > TB la: ', maxTB);

      readln;

end.

 
  
Hoàng Ngọc Hân
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 2 2023 lúc 16:00

#include <bits/stdc++.h>

using namespace std;

int n,A[100],i,dem=0;

int main()

{

cin>>n;

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

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

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

cout<<A[i]<<" ";

cout<<endl;

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

if (A[i]%2==0) dem++;

cout<<dem;

}

Nguyễn Phú Trọng
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 12 2020 lúc 22:28

uses crt;

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

 n,i,max,min,dem,t,dem1,t1,dem2,t2,dem3,t3,dem4,t4,k: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('So lon nhat trong day la: ',max);

dem:=0;

t:=0;

for i:=1 to n do 

if max=a[i] then     

begin       

inc(dem);

t:=t+a[i];       

vtmax[dem]:=i;     

end;

if dem>1 then   

begin     

writeln('Tong cac so max la: ',t);     

writeln('Cac vi tri co so max la: ');     

for i:=1 to dem do       

write(vtmax[i]:4);   

end;

min:=a[1];

for i:=1 to n do 

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

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

dem1:=0;

t1:=0;

for i:=1 to n do 

if min=a[i] then     

begin       

inc(dem1);       

t1:=t1+a[i];       

vtmin[dem1]:=i;     

end;

if dem1>1 then   

begin     

writeln('Tong cac so min la: ',t1);     

writeln('Cac vi tri co so min la: ');     

for i:=1 to dem1 do       

write(vtmin[i]:4);   

end;

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

dem2:=0;

t2:=0;

for i:=1 to n do 

if (i mod 2=0) and (a[i] mod k=0) then     

begin       

dem2:=dem2+1;       

t2:=t2+a[i];     

end;

writeln('So phan tu o vi tri chan trong day la boi cua ',k,' la: ',dem2);

writeln('Tong cac so o vi tri chan trong day la boi cua ',k,' la: ',t2);

dem3:=0;

t3:=0;

for i:=1 to n do 

if (i mod 2=1) and (k mod a[i]=0) then     

begin       

inc(dem3);       

t3:=t3+a[i];     

end;

writeln('So phan tu o vi tri le trong day la uoc cua ',k,' la: ',dem3);

writeln('Tong cac so o vi tri le trong day la uoc cua ',k,' la: ',t3);

dem4:=0;

t4:=0;

for i:=1 to n do 

if (a[i]+k=1) or (a[i]=k+1) then     

begin       

inc(dem4);       

t4:=t4+a[i];     

end;

writeln('So phan tu la anh em cua ',k,' trong day la: ',dem4);

writeln('Tong cac phan tu la anh em cua ',k,' trong day la: ',t4);

readln;

end.

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.