#include <iostream>
#include <string>
#include <algorithm>
bool P(int value)
{
std::string left = std::to_string(value);
std::reverse(left.begin(), left.end());
std::string right = std::to_string(value);;
return left == right;
}
int main()
{
int n;
std::cin >> n;
int count = 0;
for (int i = 1; i <= n; ++i)
{
if (P(i))
{
count++;
}
}
std::cout << "Count palindrome: " << count << std::endl;
return 0;
}
Pascal
Объяснение:
uses crt;
var a,b,c:real;
d:char;
label m1,m2;
begin
m1:
writeln('Введите 2 числа:');
read(a,b);
m2:
write('Выберите действие + - * /:');
read(d);
if not(d in ['+','-','*','/']) then goto m2;
case d of
'+':writeln(a+b:0:2);
'-':writeln(a-b:0:2);
'*':writeln(a*b:0:2);
'/':if b=0 then writeln('Деление на ноль невозможно')
else writeln(a/b:0:2);
end;
writeln('Продолжить? Y/y-да другое нет');
read(d);
if d in ['y','Y'] then goto m1;
end.