Những câu hỏi liên quan
Đức Anh Nguyễn
Xem chi tiết
nguyễn an phát
12 tháng 5 2021 lúc 14:40

program tinh_trung_binh_cong;

uses crt;

var i,n,max,min:integer

tbc:real;

a:array[1..100]of 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];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;

tbc:=(max+min)/2;

writeln(tbc);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
12 tháng 5 2021 lúc 18:32

uses crt;

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

i,n,max,min: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];

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((max+min)/2:4:2);

readln;

end.

Bình luận (0)
Nguyễn Thuận
Xem chi tiết
Bùi Anh Tuấn
17 tháng 3 2021 lúc 20:05

Bình luận (0)
Bùi Anh Tuấn
17 tháng 3 2021 lúc 20:05

Bình luận (0)
Nguyễn Lê Phước Thịnh
17 tháng 3 2021 lúc 21:50

Câu 3: 

uses crt;

var n,i,kt:integer;

begin

clrscr;

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

if n>1 then 

begin

kt:=0;

for i:=2 to trunc(sqrt(n)) do 

  if n mod i=0 then kt:=1;

if kt=0 then writeln(n,' la so nguyen to')

else writeln(n,' la hop so');

end

else writeln(n,' khong la so nguyen to cung khong la hop so');

readln;

end.

Bình luận (1)
Vũ hữu quyền
Xem chi tiết
nguyễn an phát
12 tháng 5 2021 lúc 14:41

program tinh_trung_binh_cong;

uses crt;

var i,n,max,min:integer

tbc:real;

a:array[1..100]of 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];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;

tbc:=(max+min)/2;

writeln(tbc);

readln;

end

Bình luận (0)
Nguyễn Lê Phước Thịnh
12 tháng 5 2021 lúc 18:32

uses crt;

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

i,n,max,min: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];

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((max+min)/2:4:2);

readln;

end.

Bình luận (0)
Nguyễn Bảo Việt
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 10 2021 lúc 0:18

Bài 2: 

#include <bits/stdc++.h>;

using namespace std;

int main();

{

long m,n;

cout<<"Nhap m="; cin>>m;

cout<<"Nhap n="; cin>>n;

cout<<m*n-2;

return 0;

}

Bình luận (0)
Ngọc hà
Xem chi tiết
Nhung
23 tháng 5 2022 lúc 22:38

program trungbinh;

uses crt;

var n,i: integer;

      s:real;

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

begin

clrscr;

write('Nhap do dai day: '); readln(n);

writeln('Nhap gia tri cua day: ');

S:=0;

for i:=1 to n do

begin

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

readln(A[i]);

S:=S+A[i];

end;

S:=S/n;

write('Trung binh cua cac so cua day do la: ',S);

readln;

end.

Bình luận (0)
Biên Vi
Xem chi tiết
Minh Nhân
5 tháng 4 2021 lúc 20:03

Tham khảo !

program trung_binh;

uses crt;

var n,i:integer;

tb:real;

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

begin

clrscr;

write('nhap n:');readln(n);

writeln('nhap day so:');

for i:=1 to n do

begin

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

end;

tb:=0;

for i:=1 to n do tb:=tb+a[i];

tb:=tb/n;

write('trung binh cong cua day so vua nhap la:',tb:2:2);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
6 tháng 4 2021 lúc 12:43

uses crt;

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

i,n,tb:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

tb:=0;

for i:=1 to n do 

  tb:=tb+a[i];

writeln(tb/n:4:2);

readln;

end.

Bình luận (0)
Leoumax
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 2 2023 lúc 20:54

Bai 2:

uses crt;

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

i,n,t,nn:integer;

begin

clrscr;

readln(n);

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

nn:=a[1];

for i:=1 to n do

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

write(nn);

readln;

end.

Bình luận (0)
Nguyễn Trần Hồng Ngọc
Xem chi tiết
Phía sau một cô gái
7 tháng 5 2023 lúc 20:02

program TinhTBCTimSoNT;

var
  ten, lop: string;
  n, i, tong, dem: integer;
  A: array [1..11] of integer;
  trung_binh: real;

function LaSoNguyenTo(x: integer): boolean;
var
  i: integer;
begin
  if x < 2 then
    LaSoNguyenTo := false
  else if x = 2 then
    LaSoNguyenTo := true
  else if x mod 2 = 0 then
    LaSoNguyenTo := false
  else
  begin
    i := 3;
    while (i <= trunc(sqrt(x))) and (x mod i <> 0) do
      i := i + 2;
    LaSoNguyenTo := x mod i <> 0;
  end;
end;

begin
  // Nhập tên và lớp của học sinh
  write('Nhập tên của học sinh: ');
  readln(ten);
  write('Nhập lớp: ');
  readln(lop);

  // Nhập dãy số nguyên và tính trung bình cộng
  repeat
    write('Nhập số phần tử của dãy số (n<12): ');
    readln(n);
  until n < 12;
  tong := 0;
  for i := 1 to n do
  begin
    write('Nhập phần tử thứ ', i, ': ');
    readln(A[i]);
    tong := tong + A[i];
  end;
  trung_binh := tong / n;

  // In tên, lớp, dãy số và trung bình cộng ra màn hình
  writeln('Học sinh: ', ten);
  writeln('Lớp: ', lop);
  write('Dãy số: ');
  for i := 1 to n do
    write(A[i], ' ');
  writeln;
 
  // In các số nguyên tố của dãy số ra màn hình
  writeln('Các số nguyên tố của dãy số:');
  for i := 1 to n do
    if LaSoNguyenTo(A[i]) then
      writeln(A[i]);
end.

Bình luận (0)
Tấn Trọng Huỳnh
Xem chi tiết