#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;
#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;
}
not(a) and (b or not(c))
Код на Python:
for a in range(0,2):
for b in range(0,2):
for c in range(0,2):
f=not(a) and (b or not(c))
print('A = ',a,'B = ',b,'C = ',c,'F = ',f)
б) А и не ( В и или не С) получим такое выражение:
a and (b or not(c))
Код на Python:
for a in range(0,2):
for b in range(0,2):
for c in range(0,2):
f=a and (b or not(c))
print('A = ',a,'B = ',b,'C = ',c,'F = ',f)
в) не ( не А или В и С) преобразуем:
a and (b or c)
Код на Python:
for a in range(0,2):
for b in range(0,2):
for c in range(0,2):
f=a and (b or c)
print('A = ',a,'B = ',b,'C = ',c,'F = ',f)