Function prime(x:integer):boolean; var t:boolean; d:integer; begin t := true; d := 2; while t and (d*d <= x) do begin if x mod d = 0 then t := false; d := d + 1 end; prime := t end;
function order(x:integer):boolean; var t:boolean; d:integer; begin d := -1; repeat t := x mod 10 > d; d := x mod 10; x := x div 10 until not t or (x = 0); order := t end;
var t:boolean; i,k,n:integer; begin t := false; read(k,n); for i := k to n do if prime(i) then if order(i) then begin write(i,' '); t := true end; if not t then write(0) end.
var
t:boolean;
d:integer;
begin
t := true;
d := 2;
while t and (d*d <= x) do
begin
if x mod d = 0 then
t := false;
d := d + 1
end;
prime := t
end;
function order(x:integer):boolean;
var
t:boolean;
d:integer;
begin
d := -1;
repeat
t := x mod 10 > d;
d := x mod 10;
x := x div 10
until not t or (x = 0);
order := t
end;
var
t:boolean;
i,k,n:integer;
begin
t := false;
read(k,n);
for i := k to n do
if prime(i) then
if order(i) then
begin
write(i,' ');
t := true
end;
if not t then
write(0)
end.
// delete.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
int num, result;
cout << "Введите четырехзначное число: ";
cin >> num; //1234
//Проверка на ввод
int p = 1;
while (p <= num)
p *= 10;
p /= 10;
if (p != 1000)
{
cout << "Вы ввели не четырехзначное число";
_getch();
return -1;
}
int thousand = num / 1000 * 1000; //1 -> 1000
int unit = num % 10; // 4
result = num % 1000 / 10; //23
result = result / 10 + result % 10 * 10; // 32
result = thousand + result * 10 + unit; //1000 + 320 + 4
cout << result; //1324
_getch();
}