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.

12 tháng 4 2018

Program Vidu;
Uses crt;

Var A:array[1..100] ò longint;

i,n,max:integer;
Begin
clrscr;

write('N= ');readln(n);
Writeln('Nhap gia tri cho mang A');
For i:=1 to n do
Begin
Write('A[',i,'] = ');
Readln(A[i]); { đọc vào giá trị cho A thứ i}
End;

max:=a[1];

for i:=1 to n do

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

write('Phan tu lon nhat la ',max);

readln

end.

15 tháng 5 2023

'''python

a. DTB = []

siso = int(input("Nhập số lượng học sinh trong lớp: "))

b. for i in range(siso):

diem = float(input(f"Nhập điểm của học sinh thứ {i+1}: "))

DTB.append(diem)

c. tong=sum(DTB)

d. print(f"Tổng điểm của lớp là: {tong}")'''

uses crt;

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

i,n:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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.

uses crt;

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

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

begin

clrscr;

n:=100;

for i:=1 to 100 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;

writeln('Day so tang dan la: ');

for i:=1 to n do 

  write(a[i]:4);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

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

cout<<endl;

t=0;

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

cout<<t;

return 0;

}

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

8 tháng 5 2023

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

i:integer;

s:longint;

Begin

For i:=1 to 50 do

Begin

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

If a[i] mod 2 <> 0 then

s:=s+a[i];

End;

Write('Tong cac so le la: ',s);

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.