Những câu hỏi liên quan
Linh Đan
Xem chi tiết
Võ Đức Dũng
17 tháng 9 2021 lúc 21:33

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.

Bình luận (1)
Võ Đức Dũng
17 tháng 9 2021 lúc 21:39

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.

Bình luận (0)
Nguyễn Thị Tươi
Xem chi tiết
evilgod709@gmail.com
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 10 2021 lúc 0:21

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,y;
    cout<<"Nhap n="; cin>>n;
    x=n;
    y=n+1;
    if (x%2==0) cout<<x-2<<endl;
    else cout<<x-1<<endl;
    if (y%5==0) cout<<y;
    else {
        while (y%5!=0)
            y++;
        cout<<y;
    }
    return 0;
}

 

Bình luận (0)
Phan Đức Duy
Xem chi tiết
hacker
10 tháng 1 2021 lúc 17:31

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.

Bình luận (0)
Minh Lệ
10 tháng 1 2021 lúc 20:09

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.

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

uses crt;

var n,d,i,t,max,x:longint;

y:integer;

st:string;

begin

clrscr;

repeat

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

until n>0;

str(n,st);

d:=length(st);

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

t:=0;

max:=0;

for i:=1 to d do 

  begin

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

t:=t+x;

if max<x then max:=x;

end;

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

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

readln;

end.

Bình luận (0)
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

Bình luận (1)
nguyễn an phát
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 3 2021 lúc 19:52

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.

Bình luận (0)
Tuoi tom May
Xem chi tiết
Phía sau một cô gái
4 tháng 5 2023 lúc 20:40

program TimMinMaxTrungBinh;

var

      N, i, max, min, sum: integer;

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

      TB, minTB, maxTB: real;

begin

      writeln('Nhap so nguyen duong N:');

      readln(N);

      sum := 0;

      for i := 1 to N do

      begin

            write('Nhap so thu ', i, ': ');

            readln(a[i]);

            sum := sum + 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;

      TB := sum / N;

      minTB := TB;

      maxTB := TB;

      for i := 1 to N do

      begin

            if (a[i] < TB) and (a[i] < minTB) then

                  minTB := a[i];

            if (a[i] > TB) and (a[i] > maxTB) then

                  maxTB := a[i];

      end;

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

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

      writeln('Gia tri trung binh la: ', TB:2:2);

      if minTB = TB then

            writeln('Khong co gia tri nao nho hon TB')

      else

            writeln('Gia tri nho nhat < TB la: ', minTB);

      if maxTB = TB then

            writeln('Khong co gia tri nao lon hon TB')

      else

            writeln('Gia tri lon nhat > TB la: ', maxTB);

      readln;

end.

 
  
Bình luận (0)
ytkc
Xem chi tiết
Nguyễn Hoàng Duy
17 tháng 6 2023 lúc 10:42

#include <iostream>

using namespace std;

int main() {
    int n;
    cout << "Nhap vao mot so nguyen khong am: ";
    cin >> n;

    int count = 0;
    for (int i = n + 1; i <= n * n; i++) {
        if (i > 0) {
            count++;
        }
    }

    cout << "So luong so duong lon hon " << n << " va nho hon hoac bang " << n * n << " la: " << count << endl;

    return 0;
}

Bình luận (0)
ytkc
15 tháng 6 2023 lúc 21:01

#include <iostream>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    cout <<n*n-n<<endl;
    return 0;
}

 

Bình luận (0)
Phúc Hưng 123 Lê Trần 12...
Xem chi tiết