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.

4 tháng 4 2023

program Tinh_Tong;

var n, s, i: integer;

begin
  write('Nhap vao so nguyen duong n: ');
  readln(n);
  s := 0;
  i := 1;
  while i <= n do
  begin
    s := s + i;
    i := i + 1;
  end;
  writeln('Tong cua ', n, ' so tu nhien dau tien la: ', s);
  end.

7 tháng 5 2023

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

14 tháng 3 2023

Program HOC24;

var i,n,max: integer;

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

begin

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

i:=1; max:=-1;

while i<=n do

begin

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

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

i:=i+1;

end;

write('So lon nhat la: ',max);

readln

end.

2 tháng 5 2023

Program HOC24;

var min,max,i,n: integer;

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

begin

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:=2 to n do

begin

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

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

end;

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

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

readln

end.

18 tháng 4 2021

program tim_uoc;

uses crt;

var i,n,tong:integer;

begin

clrscr;

write('nhap so n:');readln(n);

i:=1;tong:=0;

writeln('cac uoc cua ',n,' la:');

while i<=n do

if n mod i=0 then

begin

write(i:3);

inc(i);

end;

writeln;

i:=1;writeln('cac uoc chan:');

while i<=n do

begin

if n mod i=0 then 

begin

if i mod 2=0 then write(i:3);

tong:=tong+i;

end;

end;

writeln;

write('tong cac uoc chan:',tong);

readln;

end.

uses crt;

var n,i,t:integer;

begin

clrscr;

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

i:=1;

writeln('Cac uoc cua ',n,' la: ');

while i<=n do

  begin

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

i:=i+1;

end;

writeln;

writeln('Cac uoc chan cua ',n,' la: ');

t:=0;

i:=1;

while i<=n do 

  begin

if (n mod i=0) then

begin

t:=t+i;

write(i:4);

end;

inc(i);

end;

writeln('Tong cac uoc chan cua ',n,' la: ',t);

readln;

end.

11 tháng 4 2023

Cách 1 dùng lệnh for do:

Uses crt;

var i,n,k: integer;

begin clrcsr;

readln(n);

for i:=1 to n do begin

if(i mod 2=0) and (i>=10) then k:=k*i;

end;

writeln(k);

readln;

end.

Cách 2 dùng lệnh while do

Uses crt;

var m,n,o: integer;

begin clrcsr;

readln(n);

o:=1;

m:=1;

while (m<n) do begin

m:=m+1;

if(m mod 2=0) and (m>=10) then o:=o*m;

end;

writeln(o);

readln;

end.

17 tháng 9 2021

câu 1

Program Nguyen_to;

Var n,i:integer;

Function NT(n:integer):Boolean;

Var ok: Boolean;

i: integer;

Begin ok:=true;

for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;

if n < 2 then NT:=false else NT:=ok;

End;

Begin Write('Nhap n: ');

Readln(n); i:=n;

Repeat i:=i+1;

Until NT(i);

Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);

Readln End.

17 tháng 9 2021

câu 2

uses crt;

const so: set of char=['0','1','2','3','4','5','6','7','8','9'];

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

st,b:string;

c,l,i,n,j:integer;

s, Max: integer;

begin clrscr;

write('Nhap xau:');

readln(st);

l:=length(st);

i:=1;

n:=0;

repeat if (st[i] in so) then begin b:='';

repeat b:=b+st[i];

inc(i);

until (not(st[i] in so)) or (i>l);

inc(n);

val(b,a[n],c);

end;

inc(i);

until i>l;

Max:=a[1];

for i:=2 to n do If Max<A[i] Then Max:=A[i];

Writeln('Phan tu lon nhat cua mang:', Max);

readln;

end.

7 tháng 4 2023

program TimSoLonNhat;

var

     a, b, c, d, max: integer;

begin

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

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

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

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

     max := a;

     if b > max then

          max := b;

     if c > max then

          max := c;

     if d > max then

          max := d;

     writeln('So lon nhat la: ', max);

     readln;

end.

7 tháng 4 2023

program TimSoLonNhat;

var a, b, c, d: integer; 

begin
  writeln('Nhap vao gia tri cua a: ');
  readln(a);
  writeln('Nhap vao gia tri cua b: ');
  readln(b);
  writeln('Nhap vao gia tri cua c: ');
  readln(c);
  writeln('Nhap vao gia tri cua d: ');
  readln(d);

  if (a > b) and (a > c) and (a > d) then
    writeln('So lon nhat la: ', a)
  else if (b > a) and (b > c) and (b > d) then
    writeln('So lon nhat la: ', b)
  else if (c > a) and (c > b) and (c > d) then
    writeln('So lon nhat la: ', c)
  else
    writeln('So lon nhat la: ', d);
    readln;
end.

18 tháng 2 2023

var n, sum : integer;

begin

     write('Nhap n: ');

     readln(n);

     sum := 0;

     while n > 0 do

     begin

          sum := sum + n;

          n := n - 1;

     end;

     writeln('Tong la: ', sum);

end.