K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

uses crt;

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

n,i:integer;

s:real;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

s:=1;

for i:=1 to n do

s:=s*a[i];

writeln('Tich cac so trong day la: ',s:0:0);

readln;

end.

Câu 1: 

uses crt;

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

i,n:integer;

t:real;

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 2=0 then t:=t+a[i];

writeln(t:4:2);

readln;

end.

Câu 2: 

uses crt;

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

i,n:integer;

t:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=1;

for i:=1 to n do 

  t:=t*a[i];

writeln(t:4:2);

readln;

end.

30 tháng 3 2023

program BaiTapMang;

var
  n, i, max, min, s: longint;
  a: array[1..100] of integer;

begin
  // Nhập số phần tử của mảng
  write('Nhap so phan tu cua mang: ');
  readln(n);

  // Nhập giá trị từng phần tử của mảng
  for i := 1 to n do
  begin
    write('Nhap gia tri phan tu thu ', i, ': ');
    readln(a[i]);
  end;

  // Xuất mảng theo chiều ngang
  writeln('Mang vua nhap la:');
  for i := 1 to n do
    write(a[i], ' ');

  // Tìm giá trị lớn nhất và nhỏ nhất của mảng
  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;
  writeln;
  writeln('Gia tri lon nhat cua mang la: ', max);
  writeln('Gia tri nho nhat cua mang la: ', min);

  // Tính tổng các phần tử âm của mảng
  s:= 0;
  for i := 1 to n do
  begin
    if a[i] < 0 then
      s:= s + a[i];
  end;
  writeln('Tong cac phan tu am cua mang la: ', s);

  readln;
end.

5 tháng 4 2023

Có cách nào khác để làm nhanh hơn k

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

}

 

10 tháng 5 2023

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

i,n,max:integer;

Begin

Write('Nhap so luong phan tu n = ');readln(n);

For i:=1 to n do

Begin

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

End;

Write('Cac diem vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

max:=a[1];

For i:=2 to n do

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

write('So lon nhat la ',max);

Readln

End.

18 tháng 4 2023

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.