Những câu hỏi liên quan
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)
Nguyen Tan Dat
Xem chi tiết
Kiều Vũ Linh
19 tháng 5 2023 lúc 7:45

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

i,n:integer;

max,min,s,tb:real;

Begin

Write('Nhap so luong hoc sinh: ');readln(n);

For i:=1 to n do

Begin

Write('Nhap chieu cao hs thu ',i,' = ');readln(a[i]);

s:=s+a[i];

End;

tb:=s/n;

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('Chieu cao lon nhat la ',max:10:1);

Writeln('Chieu cao nho nhat la ',min:10:1);

Write('Chieu cao trung binh la ',tb:10:1);

Readln

End.

Bình luận (0)
Nguyễn Minh Trường
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 5 2022 lúc 23:33

#include <bits/stdc++.h>

using namespace std;

double a[1000],t;

int n,i;

int main()

{

cin>>n;

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

t=0;

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

cout<<fixed<<setprecision(2)<<t/(n*1.0);

return 0;

}

Bình luận (0)
Trần My
Xem chi tiết
Nguyễn Liên
18 tháng 4 2021 lúc 10:22

a)

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

      n,i,max,d:longint;

begin

read(n);

for i:=1 to n do

write('nhap chieu cao, don vi cm');read(a[i]);

b) max:=a[1];

for i:=2 to n do

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

writeln('ban cao nhat cao',max);

c) for i:=1 to n do

if a[i]>160 then d:=d+1;

write('so ban cao hon 160 cm la: ',d);

end.

 

Bình luận (1)
Nguyễn Lê Phước Thịnh
19 tháng 4 2021 lúc 19:34

uses crt;

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

max:real;

i,n,dem:integer;

begin

clrscr;

write('Nhap so hoc sinh:'); readln(n);

for i:=1 to n do 

  begin

write('Nhap chieu cao cua ban thu ',i,':'); readln(a[i]);

end;

max:=a[1];

for i:=1 to n do 

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

writeln('Chieu cao lon nhat la: ',max);

dem:=0;

for i:=1 to n do 

  if a[i]>1.6 then inc(dem);

writeln('So hoc sinh cao hon 1,6m la: ',dem);

readln;

end.

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)
Kim Chi
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 3 2021 lúc 19:16

uses crt;

var a:array[1..60[of real;

i,n:integer;

begin

clrscr;

write('Nhap so ban:'); readln(n);

for i:=1 to n do 

  begin

write('Chieu cao cua ban thu ',i,' la: '); readln(a[i]);

end;

for i:=1 to n do 

  writeln('Ban thu ',i,' cao ',a[i],'m');

readln;

end.

Bình luận (0)
Đỗ vantinh
Xem chi tiết
Kiều Vũ Linh
9 tháng 5 2023 lúc 16:15

Em cho thêm điều kiện loại Khá của em là gì?

Bình luận (0)
Phan Thị Phương Thy
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 4 2021 lúc 19:03

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('So lon nhat la: ',max);

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

readln;

end.

Bình luận (0)
Minh Lệ
28 tháng 4 2021 lúc 20:26

Program HOC24;

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

i,max,min,n: integer;

begin

write('Nhap so phan tu 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 a[i]>max then max:=a[i];

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

end;

writeln('So nho nhat la :',max);

write('So lon nhat la: ',min);

readln

end.

Bình luận (0)
Du Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 3 2022 lúc 23:34

uses crt;

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

t,tb,ln,nn:real;

i,n:integer;

begin

clrscr;

readln(n);

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

t:=0;

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

writeln(t:4:2);

writeln(t/n:4:2);

nn:=a[1];

ln:=a[1];

for i:=1 to n do 

begin

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

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

end;

writeln(nn);

writeln(ln);

readln;

end.

Bình luận (0)