#include <iostream>
#include <cmath>
const int length = 6;
int main()
{
int numb;
std::cout << "Input number: ";
std::cin >> numb;
if (!(numb >= (int)pow(10, length - 1) && numb < (int)pow(10, length))) {
std::cout << "\nInput error!";
}
else {
bool isPal = true;
for (int i = 0; i < length / 2; i++) {
if (((numb % (int)pow(10, i + 1) - numb % (int)pow(10, i)) / (int)pow(10, i)) != (numb / (int)pow(10, length - 1 - i) - 10 * (numb / (int)pow(10, length - i {
isPal = false;
std::cout << "\nIt's" << (isPal ? "" : " not a") << " palindrome";
return 0;
var a, b, с: integer;
begin
write('Введите два числа: ');
readln(a, b);
if a < b then с := a + 1 else с := b + 1;
repeat с := с - 1
until (a mod с = 0) and (b mod с = 0);
write('NOD = ', с)
end.
//2. Алгоритм с вычитанием (цикл while)
var a, b: integer;
write('a = ');
readln(a);
write('b = ');
readln(b);
while a <> b do
if a > b then
a := a - b
else
b := b - a;
writeln('NOD = ', a);
#include <iostream>
#include <cmath>
const int length = 6;
int main()
{
int numb;
std::cout << "Input number: ";
std::cin >> numb;
if (!(numb >= (int)pow(10, length - 1) && numb < (int)pow(10, length))) {
std::cout << "\nInput error!";
}
else {
bool isPal = true;
for (int i = 0; i < length / 2; i++) {
if (((numb % (int)pow(10, i + 1) - numb % (int)pow(10, i)) / (int)pow(10, i)) != (numb / (int)pow(10, length - 1 - i) - 10 * (numb / (int)pow(10, length - i {
isPal = false;
}
}
std::cout << "\nIt's" << (isPal ? "" : " not a") << " palindrome";
}
return 0;
}
var a, b, с: integer;
begin
write('Введите два числа: ');
readln(a, b);
if a < b then с := a + 1 else с := b + 1;
repeat с := с - 1
until (a mod с = 0) and (b mod с = 0);
write('NOD = ', с)
end.
//2. Алгоритм с вычитанием (цикл while)
var a, b: integer;
begin
write('a = ');
readln(a);
write('b = ');
readln(b);
while a <> b do
if a > b then
a := a - b
else
b := b - a;
writeln('NOD = ', a);
end.