Var
N,A:integer;
Begin
Write('N = ');Read(N);
A:=0;
While N>0 do
if (N mod 10) > A then A:= N mod 10;
N:=N div 10;
End;
Write(A)
End.
N,A,B:integer;
C:boolean;
A:=-1;
B:=-2;
C:=false;
if A=B then C:=true;
if N>0 then
A:=N mod 10;
B:=N mod 10;
if C then Write('Есть')
else Write('Нет')
Подробнее - на -
#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
N,A:integer;
Begin
Write('N = ');Read(N);
A:=0;
While N>0 do
Begin
if (N mod 10) > A then A:= N mod 10;
N:=N div 10;
End;
Write(A)
End.
Var
N,A,B:integer;
C:boolean;
Begin
Write('N = ');Read(N);
A:=-1;
B:=-2;
C:=false;
While N>0 do
Begin
if A=B then C:=true;
if N>0 then
Begin
A:=N mod 10;
N:=N div 10;
End;
if A=B then C:=true;
if N>0 then
Begin
B:=N mod 10;
N:=N div 10;
End;
End;
if A=B then C:=true;
if C then Write('Есть')
else Write('Нет')
End.
Подробнее - на -
#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;
}