#include<stdio.h> int main() { int a, b, c; scanf("%d %d %d", &a,&b,&c); if(a > b) { b = a + b; a = b - a; b = b - a; } if(a > c) { c = a + c; a = c - a; c = c - a; } if(b > c) { c = b + c; b = c - b; c = c - b; } printf("a: %d\nb: %d\nc: %d", a, b, c); }
注意:要先a > b,再a > c,最后b > c,这个顺序不能颠倒!!!前两步是为了先确定最小值a !!!
注意:要先a > b,再a > c,最后b > c,这个顺序不能颠倒!!!前两步是为了先确定最小值a !!!
注意:要先a > b,再a > c,最后b > c,这个顺序不能颠倒!!!前两步是为了先确定最小值a !!!
标签:顺序,int,两步,整数,颠倒,最小值,三个,排序 From: https://www.cnblogs.com/algorithm-code/p/three-int-sort.html