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.

Bài 1:

uses crt;
var n,kt,i,n1,i1:integer;
begin
clrscr;
write('nhap n='); readln(n);
if n>=0 then
begin
write(n,'=');
n1:=n;
i1:=2;
repeat
while n1 mod i1<>0 do
i1:=i1+1;
write(i1);
n1:=n1 div i1;
if n1>1 then write('*');
until n1=1;
end
else writeln('vui long nhap so tu nhien');
readln;
end.

Bài 2:

uses crt;
var n,d,i,x,t,ln:integer;
st:string;
a:array[1..100]of integer;
begin
clrscr;
write('nhap n='); readln(n);
if n>0 then
begin
str(n,st);
d:=length(st);
for i:=1 to d do
val(st[i],a[i],x);
t:=0;
for i:=1 to d do
t:=t+a[i];
writeln('tong cac chu so cua so ',n,' la: ',t);
writeln('so ',n,' co ',d,' chu so');
ln:=0;
for i:=1 to d do
if ln<a[i] then ln:=a[i];
writeln('chu so lon nhat cua so ',n,' la: ',ln);
end
else writeln('vui long nhap lai');
readln;
end.

Bài 3:

uses crt;
var n,i,dem,ln:integer;
a:array[1..100]of integer;
begin
clrscr;
write('nhap n='); readln(n);
ln:=0;
for i:=n div 2 downto 1 do
if n mod i=0 then if (i mod 2=1) and (ln<i) then ln:=i;
writeln(ln);
readln;
end.

Bài 4:

uses crt;
var n,i,d,x,nn,dem:integer;
st:string;
a,b:array[1..100]of integer;
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);
for i:=1 to d do
if a[i] mod 2=0 then
begin
dem:=dem+1;
b[dem]:=a[i];
end;
nn:=b[1];
for i:=1 to dem do
if nn>b[i] then nn:=b[i];
writeln('so chan be nhat trong so ',n,' la: ',nn);
readln;
end.

Bài 5:

uses crt;
var n,d,i:integer;
st:string;
begin
clrscr;
write('nhap n='); readln(n);
str(n,st);
d:=length(st);
for i:=d downto 1 do
write(st[i]);
readln;
end.

Bài 6:

uses crt;
var n:integer;
st:string;
begin
clrscr;
write('nhap n='); readln(n);
str(n,st);
writeln('so dau tien tinh tu trai qua phai cua so ',n,' la: ',st[1]);
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.

14 tháng 5 2021

Bài 1:program sothuc;

uses crt;

var a:array[1..10] of real;s,i,j:real;

begin

s:=0;

for i:=1 to 10 do begin writeln('A[',i,']=');readln(a[i]); end;

for i:=1 to 10 do if a[i]<0 then

for j:=1 to 10 do

begin a[j]:=sqr(a[i]); s:=s+a[j]; end;

writeln('tong binh phuong cac so am la: ',s:2:2); readln;

end. (Khi nào mình kiểm tra chạy lại trên phần mềm rồi sửa lại nếu sai nhé)

Bài 2: 

program soduong;

uses crt;

var a:array[1..100] of integer;s,i,n:integer;

begin

clrscr;

writeln('nhap do dai cua day');readln(n);

for i:=1 to n do begin

writeln('a[',i,']=');readln(a[i]);

if a[i] mod 2 = 0 then s:=s+a[i] end;

writeln('tong so duong trong day la',s:2:0);readln

end.

Bài 3: các số dương mà là số lẻ là sao thế bạn????

uses crt;

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

i,n,dem:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

dem:=0;

for i:=1 to n do 

  if (10<a[i]) and (a[i]<20) then inc(dem);

writeln(dem);

readln;

end.

13 tháng 4 2021

Em cảm ơn ạ!

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.

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.

6 tháng 4 2023

Bài 1:

Program HOC24;

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

i,n,d: integer;

begin

write('Nhap so phan tu: '); readln(n);

for i:=1 to n do 

begin

write('Nhap so thu ',i,': '); readln(a[i]);

end;

for i:=1 to n do if (a[i]<0) and (a[i] mod 2=0) then d:=d+1;

write('Co ',d,' so nguyen am chan trong day so');

readln

end.

6 tháng 4 2023

Bài 2:

Program HOC24;

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

i,n: integer;

t: longint;

begin

write('Nhap so phan tu: '); readln(n);

for i:=1 to n do 

begin

write('Nhap so thu ',i,': '); readln(a[i]);

end;

t:=0;

for i:=1 to n do if a[i] mod 5=0 then t:=t+a[i];

write(Tong la: ',t);

readln

end.

a)

uses crt;

var n,i,kt,j:integer;

begin

clrscr;

repeat

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

until n>1;

writeln('Cac so nguyen to be hon hoac bang ',n,' la: ');

for i:=2 to n do 

begin

kt:=0;

for j:=2 to i-1 do 

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

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

end;

readln;

end.

uses crt;

var n,i,d,x,j,tam:longint;

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

st:string;

begin

clrscr;

repeat

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

until n>0;

str(n,st);

d:=length(st);

for i:=1 to d do 

  begin

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

end;

for i:=1 to d-1 do 

  for j:=i+1 to d do 

if a[i]<a[j] then 

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

end;

for i:=1 to d do 

  write(a[i]);

readln;

end.