Skip to content

Instantly share code, notes, and snippets.

@dd1994
Created May 12, 2014 02:49
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 dd1994/73408a4cfc124b2cac1e to your computer and use it in GitHub Desktop.
Save dd1994/73408a4cfc124b2cac1e to your computer and use it in GitHub Desktop.
#include <stdio.h>
void rank(int *p1, int *p2, int *p3);
void swap(int *p1, int *p2);
int main(void)
{
int a, b, c;
while(scanf("%d %d %d", &a, &b, &c) != EOF) {
rank(&a, &b, &c);
printf("%d %d %d\n", a, b, c);
}
return 0;
}
void rank(int *p1, int *p2, int *p3)
{
swap(p1, p2);
swap(p1, p3);
swap(p2, p3);
}
void swap(int *p1, int *p2)
{
int temp;
if(*p1 > *p2)
{
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment