#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;
Поделитесь своими знаниями, ответьте на вопрос:
4)Что будет выведено на экран после выполнения фрагмента программы: begina:=10;if a>30 then а:=5 else a:=a+1;writeln (а);end.
#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;
}