#include <stdio.h>

void sort(int *x, int *y, int *z);


int main()

{

    int x=4, y=11, z=8;

    sort(&x, &y, &z);

    printf("%d %d %d\n",x,y,z);

}



void sort(int *x, int *y, int *z){

    int temp;

    if(*x < *y){

        temp = *x;

        *x = *y;

        *y = temp;

        sort(x, y, z);

    }

    else if(*y < *z){

        temp = *y;

        *y = *z;

        *z = temp;

        sort(x, y, z);

    }

    else if(*x < *z){

        temp = *x;

        *x = *z;

        *z = temp;

        sort(x, y, z);

    }

}



'Programing > Algorithm' 카테고리의 다른 글

Recursive Fibonacci  (0) 2015.04.06
순환/재귀 팩토리알 구현  (0) 2015.04.06
프로젝트 오일러 7번  (0) 2015.02.10
프로젝트 오일러 6번  (0) 2015.02.10
프로젝트 오일러 5번  (0) 2015.02.10
Posted by kimmayer

블로그 이미지
IT 기술들 정리, 독후감을 주로 남깁니다!
kimmayer

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.3
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함