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.

7 tháng 2 2023

program ct;
uses crt;
var dem,n,s,max,t:longint;
begin
        writeln('nhap n:');readln(n);
        while n>0 do begin
                        s:=n mod 10;
                        t:=t+s;
                        if max<s then max:=s;
                        dem:=dem+1;
                        n:=n div 10;
                     end;
        writeln('tong la',t,',','co',' ',dem,' ','chu so',',','chu so lon nhat la:',max);
        readln
end.

bạn xem lại nha mik làm đây nhưng k bt đk

uses crt;

var n,i,d,dem,kt,t,kt1,t1,t2,t3,max,min,x,j:integer;   

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

st:string;

begin

clrscr;

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

str(n,st);

d:=length(st);

for i:=1 to d do 

val(st[i],a[i],x);

dem:=1;

b[1]:=a[1];

for i:=1 to d do 

begin     

kt:=0;     

for j:=1 to dem do       

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

if kt=0 then       

begin           

inc(dem);           

b[dem]:=a[i];       

end; 

end;

writeln('Cac chu so cua ',n,' la: ');

for i:=1 to dem do 

write(b[i]:4);

writeln;

t:=0;

for i:=1 to d do 

t:=t+a[i];

writeln('Tong cac chu so cua ',n,' la: ',t);

kt1:=0;

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

if t mod i=0 then     

begin       

kt1:=1;       

break;     

end;

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

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

writeln('Cac chu so o vi tri le cua ',n,' la: ');

t1:=0;

for i:=1 to d do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac chu so o vi tri le la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac chu so o vi tri chan cua ',n,' la: ');

t2:=0;

for i:=1 to d do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln('Tong cac chu so o vi tri chan la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if (t3=t2) and (t2>0) then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to d do 

begin     

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

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

end;

writeln('Chu so lon nhat cua ',n,' la: ',max);

writeln('Chu so nho nhat cua ',n,' la: ',min);

writeln('Tong cua chung la: ',max+min);

readln;

end.

10 tháng 1 2021

uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.

10 tháng 1 2021

Program HOC24;

var N:longint;

max,tg,t,d: integer;

Begin

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

max:=0;

while n<>0 do

begin

tg:=n mod 10;

d:=d+1;

t:=t+tg;

if tg>max then max:=tg;

n:=n div 10;

end;

writeln('So nguyen N co ',d,' chu so');

writeln('Tong cac chu so cua N la : ',t);

write('Chu so lon nhat cua N la :',max);

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

 

13 tháng 12 2020

uses crt;

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

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

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

writeln('Cac so vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln('Tong cua day so la: ',t);

kt:=0;

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

  if t mod j=0 then 

    begin

kt:=1;

break;

end;

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

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

readln;

end.

13 tháng 12 2020

Cậu ơi sai khúc write('A[',i,']='); readln(a[i]); rồi nó cứ bị sao sao á

 

13 tháng 12 2020

uses crt;

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

i,n,t,kt:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

writeln('Cac so ban vua nhap la: ');

for i:=1 to n do 

write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do

t:=t+a[i];

writeln('Tong cac so vua nhap la: ',t);

if t>=2 then 

begin

kt:=0;

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

  if t mod i=0 then 

begin

kt:=1;

break;

end;

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

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

end

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

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.

 

9 tháng 3 2023

var i,n,s,du,dem:integer;

Begin

While n<=0 do

Begin

Write('N = ');readln(n);

End;

For i:=1 to n do

If n mod i = 0 then

Begin

Write(i:7);

du:=du+1;

s:=s+i;

End;

Writeln('So uoc cua ',n,' la ',du);

Writeln('Tong cac uoc cua ',n,' la ',s);

For i:=1 to s do

If s mod i = 0 then dem:=dem+1;

If dem=2 then write(s,' la so nguyen to')

Else write(s,' khong la so nguyen to');

Readln;

End.

9 tháng 3 2023

Cám ơn nhiều

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.

uses crt;

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

i,n,t,t1,t2,t3,min,max:integer;   

kt:boolean;

begin

clrscr;

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

for i:=1 to n do 

begin     

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

end;

writeln('Day so ban vua nhap la: ');

for i:=1 to n do 

write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

t:=t+a[i];

kt:=true;

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

if t mod i=0 then     

begin       

kt:=false;       

break;     

end;

writeln('Tong cua day so la: ',t);

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

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

writeln('Cac so o vi tri le cua day so la: ');

t1:=0;

for i:=1 to n do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri le cua day so la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac so o vi tri chan cua day so la: ');

t2:=0;

for i:=1 to n do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri chan cua day so la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if t3=t2 then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

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 cua day la: ',max);

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

writeln('Tong cua so lon nhat va so nho nhat la: ',max+min);

readln;

end.