Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // apple xcode
- // paulogp
- /* numero que se le igualmente da direita para a esquerda ou vice-versa e
- ao qual se atribui boa sorte */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define MAX_INTERVAL 1000000
- int func_invert(int the_number) {
- // inverte numero
- int the_remainder;
- int the_result;
- while (the_number != 0) {
- the_remainder = the_number % 10;
- the_number = the_number / 10;
- the_result = the_result * 10 + the_remainder;
- }
- return the_result;
- }
- int main (int argc, const char * argv[]) {
- // capicua
- int the_number = 0;
- int the_capicua = 0;
- // insert number
- printf("numero: ");
- scanf("%i", &the_number);
- // put some limits
- if ((the_number >= -MAX_INTERVAL) && (the_number <= MAX_INTERVAL)) {
- // invert
- the_capicua = func_invert(the_number);
- printf("numero: %i, invertido: %i\n", the_number, the_capicua);
- // capicua?
- if (the_number == the_capicua) {
- printf("capicua\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement