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.

uses crt;

var n,m,i,dem,t,t1,d1:integer;

//chuongtrinhcon

function ktnt(var n:integer):boolean;

var i:integer;

kt:boolean;

begin

kt:=true;

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

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

if (kt=true) then ktnt:=true

else ktnt:=false;

end;

//chuongtrinhchinh

begin

clrscr;

readln(n,m);

if (ktnt(n)=true) then writeln(n,' la so nguyen to')

else writeln(n,' ko la so nguyen to');

dem:=0;

t:=0;

for i:=2 to n do 

  if (ktnt(i)=true) then

begin

write(i:4);

t:=t+i;

dem:=dem+1;

end;

writeln;

writeln(t,' ',dem);

t1:=0;

d1:=0;

for i:=n to m do 

  if ktnt(i)=true then

begin

write(i:4);

t1:=t1+i;

inc(d1);

end;

writeln;

writeln(t1,' ',d1);

readln;

end.

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;

}

1:

uses crt;

var t,x,i,n:integer;

begin

clrscr;

t:=0;

n:=10;

for i:=1 to n do

begin

readln(x);

t:=t+x;

end;

write(t);

readln;

end.

2: 

uses crt;

var dem,x,i,n:integer;

begin

clrscr;

dem:=0;

n:=10;

for i:=1 to n do

begin

readln(x);

if x mod 2=0 then inc(dem);

end;

write(dem);

readln;

end.

4 tháng 4 2023

3

program Cacsole;
uses crt;
var M, N, i: integer;
begin
clrscr;
write ('Nhap M= '); readln(M);
write ('Nhap N= '); readln(N);
for i := M to N do

if  i mod 2 = 1 then
write (i,' ');
readln;
end.

Câu 1: 

uses crt;

var n,i,dem,j,kt1,kt2,a,b,kt:integer;

begin

clrscr;

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

dem:=0;

if n mod 2=1 then   

begin     

a:=2;     

b:=n-a;     

kt:=0;     

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

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

if kt=0 then inc(dem);   

end

else begin       

              for i:=2 to n div 2 do         

begin             

a:=i;             

b:=n-i;             

kt1:=0;             

kt2:=0;             

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

if a mod j=0 then kt1:=1;             

for j:=2 to trunc(sqrt(b)) do               

if b mod j=0 then kt2:=1;             

if (kt1=0) and (kt2=0) then inc(dem);         

end;     

end;

writeln('So cach phan tich ',n,' thanh tong hai so nguyen to la: ',dem);

readln;

end.

Câu 2: 

uses crt;

var n,x:integer;

{-----------------ham-kiem-tra-nguyen-to-----------------}

function ktnt(x:integer):boolean;

var kt:boolean;   

i:integer;

begin   

kt:=true;   

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

if x mod i=0 then       

begin           

kt:=false;           

break;       

end;   

if kt=true then ktnt:=true   

else ktnt:=false;

end;

{---------------ham-kiem-tra-so-doi-xung---------------}

function ktdx(x:integer):boolean;

var kt:boolean;   

d,i:integer;   

st:string;

begin   

str(x,st);   

d:=length(st);   

kt:=true;   

for i:=1 to d do     

if st[i]<>st[d-i+1] then       

begin           

kt:=false;           

break;       

end;   

if kt=true then ktdx:=true   

else ktdx:=false;

end;

{--------------chuong-trinh-chinh---------------}

begin

clrscr;

repeat   

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

until n>0;

if (ktnt(n)=true) and (ktdx(n)=true) then writeln(n,' la so nguyen to doi xung')

else writeln(n,' khong la so nguyen to doi xung');

x:=n+1;

repeat   

x:=x+1;

until (ktnt(x)=true) and (ktdx(x)=true);

writeln('So nguyen to doi xung nho nhat lon hon ',n,' la: ',x);

readln;

end.

15 tháng 1 2021

Mình cảm ơn bạn nhiều nha

 

5 tháng 1 2023

uses crt;

var n,i,s,t,j,max:longint;a,b:array[1..100] of longint;tbc:real;

function snt(n:longint):boolean;

var j:longint;

begin

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

if n mod j=0 then exit(false);

exit(n>1);

end;

begin

readln(N);

for i:=1 to n do

begin

read (a[i]);

if snt(a[i])=true then 

begin

j:=j+1;

b[j]:=a[i];

end;

end;

t:=b[1];

max:=b[1];

for i:=2 to j do

begin

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

t:=t+b[i];

write(b[i]:4);

end;

tbc:=t/j;

writeln(S);

writeln(tbc);

writeln(max);

readln;

end.

 

 

 

Bài 1: 

uses crt;

var n,i,kt:integer;

begin

clrscr;

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

kt:=0;

for i:=2 to n-1 do 

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

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

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

readln;

end.

Bài 2: 

uses crt;

var n,i:integer;

begin

clrscr;

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

for i:=1 to n do 

 if n mod i=0 then write(i:4);

readln;

end.

1 tháng 9 2021

program bai_1;
uses crt;
var i,n,j,d,dem:word;
begin
  clrscr;
  repeat
    write('nhap n:');readln(n);
    if (n<=0)or(n>=10000)then writeln('so ban nhap khong hop le, ban hay nhap lai:');
  until (n>0)and(n<10000);
  writeln('cac uoc so la so tu nhien cua ',n,' la:');
  for i:=1 to n do
  if n mod i=0 then write(i,'    ');
  writeln;
  dem:=0;
  for i:=2 to n do
  begin
    d:=0;
    for j:=2 to i div 2 do
    if i mod j=0 then inc(d);
    if (d=0)and(n mod i=0)then inc(dem);
  end;
  if dem>0 then writeln('cac uoc so la so nguyen to cua ',n,' la:');
  begin
    d:=0;
    for j:=2 to i div 2 do
    if i mod j=0 then inc(d);
    if (d=0)and(n mod i=0)then write(i,'    ');
  end;
  if dem=0 then write(0);
  readln;
end.

 

29 tháng 3 2022

Var i,n,dem:integer;

begin

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

for i:=1 to n do

if n mod i = 0 then dem:=dem+1;

if dem=2 then write(n,' la so nguyen to')

else write(n,' khong la so nguyen to');

readln;

end.

#include <bits/stdc++.h>

using namespace std;

int n,kt,t;

int main()

{

cin>>n;

int t=0;

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

if (i%2==1) cout<<i<<" ";

cout<<endl;

for (int i=2; i<=n; i++)

{

kt=0;

for (int j=2; j*j<=i; j++)

if (i%j==0) kt=1;

if (kt==0) cout<<i<<" ";

}

return 0;

}