Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int switcher (int number) {
- if(number == 0)
- return 0;
- if(number%10 == 9)
- return 7 + 10 * switcher (number/10);
- else
- return number%10 + 10 * switcher (number/10);
- }
- int sort (int array[], int N) {
- for(int i=0; i<N; i++) {
- for(int j=0; j<N-1; j++) {
- if(array[j] > array[j+1]) {
- int temp = array[j];
- array[j] = array[j+1];
- array[j+1] = temp;
- }
- }
- }
- }
- int print (int array[], int N) {
- int size = 5;
- if(N < 5)
- size = N;
- for(int i=0; i<size; i++)
- printf("%d ",array[i]);
- }
- int main () {
- int array [100], number, N = 0;
- while(scanf("%d",&number)) {
- array[N++] = switcher(number);
- }
- sort(array,N);
- print(array,N);
- }
Advertisement
Add Comment
Please, Sign In to add comment