三变量从小到大的排序

#include<math.h>
#include<stdio.h>
using namespace std;
#pragma warning(disable:4996)
int main()
{
//三变量比较
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int t;
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	if (a > c) {
		t = a;
		a = c;
		c = t;
	}
	if (b > c) {
		t = b;
		b = c;
		c = t;
	}
	printf("%d %d %d", a, b, c);
	
}

猜你喜欢

转载自blog.csdn.net/weixin_45929885/article/details/113407079
今日推荐