For example, my variable valor
has the value 1354 , note that 13 appears in this numeric value . How can I identify a specific number in any other numeric value?
I would like an example in C.
The following is the problem statement:
China is building a space elevator, which will allow the launch of probes and satellites to a much lower cost, enabling not only scientific research projects such as space tourism. However, the Chinese are very superstitious, so they are very lift floors: they do not use any number that contains the digit "4" or sequence of digits "13". Thus, they do not use floor 4, floor 13, floor 134, nor floor floor 113, but use floor 103. Thus, the first floors are numbered 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 15, 16. . . As the space elevator has many floors, and they need to number all floors of the elevator, the Chinese asked you to write a program that, given the floor, indicates the number you should be assigned to it
I have identified a way to check if the last digit ends with 4, follows the example:
int andar(int numero)
{
int sobra = 0;
int resultado;
sobra = numero % 10;
if (sobra == 4)
{
resultado = numero + 1;
}
else
{
resultado = numero;
}
return resultado;
}
My question is how to identify 13 and 4 in any number.