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
Minh Hoạt
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 4 2021 lúc 12:38

uses crt;

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

i,n,dem,t,tb:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem:=0;

t:=0;

for i:=1 to n do 

  if a[i]>0 then

begin

dem:=dem+1;

t:=t+a[i];

end;

writeln('So luong phan tu duong la: ',dem);

writeln('Tong cac phan tu duong la: ',t);

writeln('Trung binh cac phan tu duong la: ',t/dem:4:2);

readln;

end.

nguyễn thị châu
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 2 2022 lúc 0:10

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

cin>>k;

kt=false;

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

if (a[i]==k)

{

cout<<i<<" ";

kt=true;

}

cout<<endl;

if (kt==false) cout<<"Khong co so k trong day"<<endl;

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

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

return 0;

}

Nguyễn Huỳnh Mai Trân
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 4 2022 lúc 22:05

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,a[1000],t;

int main()

{

cin>>n;

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

cin>>x;

t=0;

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

if (a[i]!=x) 

{

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

t+=a[i];

}

cout<<endl;

cout<<t;

return 0;

}

bui pham phuong Uyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 1 2021 lúc 13:15

Bài 1: 

uses crt;

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

i,n,kt,max,x,j,tam:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

writeln('Mang ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

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('Day tang dan la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

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

max:=0;

kt:=0;

for i:=1 to n do 

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

   begin

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

kt:=1;

end;

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

else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);

readln;

end.

Danh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 7:23

Bài 1:

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if ((x<0) and (x%2!=0)) t=t+x;

}

cout<<t;

return 0;

}

hien nguyen
Xem chi tiết
Nguyen
19 tháng 3 2019 lúc 5:45

uses crt;
const MN = 100;
var
a: array [1..MN] of integer;
n: integer;
Procedure Gen(m: integer);
var i: integer;
begin
Writeln('Hay nhap n:');​

Readln(n);

randomize; n := m;
for i := 1 to n do a[i] := random(m);

writeln(a[i]);

readln;
end.

Bastkoo Đúng chưa bạn?

Nguyễn Lê Phước Thịnh
13 tháng 10 2019 lúc 11:49

uses crt;
var a:array[1..100]of integer;
i,j,n:integer;
begin
clrscr;
randomize;
write('nhap n='); readln(n);
for i:=1 to n do
a[i]:=random(4)+1;
for i:=1 to n do write(a[i]:4);
readln;
end.

nông thị ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 3 2021 lúc 19:41

uses crt;

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

n,i,k,t,t1: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);

t:=0;

for i:=1 to n do 

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

t1:=0;

for i:=1 to n do 

  if a[i] mod k=0 then t1:=t1+a[i];

writeln('Tong cac phan tu le la: ',t);

writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);

readln;

end.

An An Nguyễn
Xem chi tiết
duyy
Xem chi tiết
Edward Paros
18 tháng 4 2023 lúc 22:31

program Tinh_Tong_Phan_Tu_Chan;

var
  A: array of Integer;
  N, i, sum: Integer;

begin
  Write('Nhap N: ');
  Readln(N);

  SetLength(A, N);

  // Nhập các phần tử cho mảng A
  for i := 0 to N - 1 do
  begin
    Write('Nhap phan tu thu ', i + 1, ': ');
    Readln(A[i]);
  end;

  // In lên màn hình các phần tử của mảng A
  Write('Cac phan tu cua mang la: ');
  for i := 0 to N - 1 do
  begin
    Write(A[i], ' ');
  end;
  Writeln;

  // Tính tổng các phần tử chẵn của mảng A và thông báo kết quả ra màn hình
  sum := 0;
  for i := 0 to N - 1 do
  begin
    if A[i] mod 2 = 0 then
      sum := sum + A[i];
  end;
  Writeln('Tong cac phan tu chan cua mang la: ', sum);

  Readln;
end.