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
Nguyễn Phi Tú
Xem chi tiết
Đoàn Thị Thu Hà
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 12 2020 lúc 23:27

uses crt;

var a,t,dem:integer;

begin

clrscr;

t:=0;

dem:=0;

repeat

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

if (a mod 2=0) and (a mod 3=0) then

  begin

    t:=t+a;

dem:=dem+1;

end;

until a=0;

writeln('Trung binh cong cua cac so chia het cho 3 va 2 la: ',t/dem:4:2);

readln;

end.

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.

Thư Huỳnhh
Xem chi tiết
Nguyễn Anh Dũng
9 tháng 12 2021 lúc 20:04

var m,n: integer;

begin

    writeln(' nhap so nguyen a: ');

    read(a);

    writeln(' nhap so nguyen b: ');

    read(b);

    writeln((m + n)/2);

    readln;

end.

Tuoi tom May
Xem chi tiết
Phía sau một cô gái
4 tháng 5 2023 lúc 20:40

program TimMinMaxTrungBinh;

var

      N, i, max, min, sum: integer;

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

      TB, minTB, maxTB: real;

begin

      writeln('Nhap so nguyen duong N:');

      readln(N);

      sum := 0;

      for i := 1 to N do

      begin

            write('Nhap so thu ', i, ': ');

            readln(a[i]);

            sum := sum + a[i];

      end;

      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;

      TB := sum / N;

      minTB := TB;

      maxTB := TB;

      for i := 1 to N do

      begin

            if (a[i] < TB) and (a[i] < minTB) then

                  minTB := a[i];

            if (a[i] > TB) and (a[i] > maxTB) then

                  maxTB := a[i];

      end;

      writeln('Gia tri lon nhat la: ', max);

      writeln('Gia tri nho nhat la: ', min);

      writeln('Gia tri trung binh la: ', TB:2:2);

      if minTB = TB then

            writeln('Khong co gia tri nao nho hon TB')

      else

            writeln('Gia tri nho nhat < TB la: ', minTB);

      if maxTB = TB then

            writeln('Khong co gia tri nao lon hon TB')

      else

            writeln('Gia tri lon nhat > TB la: ', maxTB);

      readln;

end.

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

Bùi Anh Tuấn
17 tháng 3 2021 lúc 20:05

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.

M Ạ C H N H A
Xem chi tiết
Phú Lưu
Xem chi tiết
Kiều Vũ Linh
20 tháng 4 2022 lúc 14:52

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

max,min:integer;

tbc:real;

Begin

For i:=1 to 20 do

Begin

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

End;

Max:=a[1];

Min:=a[1];

For i:=2 to 20 do

Begin

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

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

End;

tbc:=(max+min)/2;

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

Writeln('So nho nhat la ',min);

Write('Trung binh cong la ',tbc:10:2);

Readln;

End.

Đứ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.

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.