Last active
December 18, 2016 18:51
-
-
Save fjolnir/a05e02cb91c6a825d1922588239e6762 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int removeLastOddDigit(int num) | |
{ | |
for (int base = 1; num/base != 0; base *= 10) { | |
if ((num/base) % 2 != 0) { | |
return base * (num/(base*10)) + num%base; | |
} | |
} | |
return num; | |
} | |
int main(int argc, char *argv[]) { | |
printf("%d", removeLastOddDigit(-446823882)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment