Created
March 14, 2018 13:34
-
-
Save anonymous/37da98d56f71ba62df6ecd96adef6620 to your computer and use it in GitHub Desktop.
SortDigits F
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
#include <stdio.h> | |
int F(int N){ | |
int d1, d2, temp; | |
if (N<10) return N; | |
else | |
{ | |
d1=N%10; | |
N=N/10; | |
N=F(N); | |
d2=N%10; | |
if (d1<=d2) return N*10+d1; | |
else | |
{ | |
N=((N/10)*100) + (d1*10) + d2; | |
temp=F(N/10); | |
return (temp*10) + (N%10); | |
} | |
} | |
} | |
void main() | |
{ | |
int n = 23989769; | |
printf("Fix number: %d\n", F(n)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment