Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Last active December 18, 2016 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjolnir/a05e02cb91c6a825d1922588239e6762 to your computer and use it in GitHub Desktop.
Save fjolnir/a05e02cb91c6a825d1922588239e6762 to your computer and use it in GitHub Desktop.
#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