Những câu hỏi liên quan
Vũ Ngọc Lan
Xem chi tiết
Phan Thu
Xem chi tiết
Phương Linh
Xem chi tiết
haizzz!!
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:13

uses crt;

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

i,n,j,kt:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

for i:=1 to n do 

  if a[i]>1 then

begin

kt:=0;

for j:=2 to a[i]-1 do 

 if a[i] mod j=0 then kt:=1;

if kt=0 then write(a[i]:4);

end;

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)
Phạm Thị Kim Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 4 2022 lúc 17:09

uses crt;

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

i,n,t,kt,j:integer;

begin

clrscr;

readln(n);

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

t:=0;

for i:=1 to n do 

if a[i] mod 2<>0 then t:=t+a[i];

writeln(t);

for i:=1 to n do 

  if trunc(sqrt(a[i]))=sqrt(a[i]) then write(a[i]:4);

writeln;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then write(a[i]:4);

end;

readln;

end.

Bình luận (0)
8/1 Ngọc Hân
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 22:26

c: 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

cin>>n;

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

for (i=1; i<=n; i++)

if (a[i]%2==0) cout<<a[i]<<" ";

return 0;

}

d: 

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn;

return 0;

}

Bình luận (0)
Bảo Nguyễn
Xem chi tiết
Anh Thư
Xem chi tiết
Minh Lệ
10 tháng 4 2021 lúc 18:25

Program HOC24;

var d,i,n: integer;

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

t: longint;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do

begin

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

end;

d:=0; t:=0;

for i:=1 to n do

if nt(a[i]) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' so nguyen to trong day');

write('Tong cac so nguyen to trong day la: ',t);

readln

end.

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

uses crt;

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

i,n,dem,t,j,kt:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem:=0;

t:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to a[i]-1 do 

 if a[i] mod j=0 then kt:=1;

if kt=0 then

begin

inc(dem);

t:=t+a[i];

end;

end;

writeln('So luong so nguyen to la: ',dem);

writeln('Tong cac so nguyen to la: ',t);

readln;

end.

Bình luận (0)