Created
July 4, 2015 15:29
-
-
Save icemilo/b20674494be1f6102e47 to your computer and use it in GitHub Desktop.
Inverse Integer
This file contains 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
// | |
// main.c | |
// InverseNumber | |
// | |
// Created by JAE SEUNG KOO on 7/4/15. | |
// Copyright (c) 2015 JAE SEUNG KOO. All rights reserved. | |
// | |
#include <stdio.h> | |
void inverse_num(int); | |
int main(int argc, const char * argv[]) { | |
int num = 0; | |
printf("input number : "); | |
scanf("%d", &num); | |
for(;num%10==0;num=num/10); | |
if(num < 0){ | |
num *= -1; | |
printf("-"); | |
} | |
inverse_num(num); | |
return 0; | |
} | |
void inverse_num(int num){ | |
if(num == 0) | |
return; | |
printf("%d", num%10); | |
inverse_num(num/10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment