如愿以偿

#include<bits/stdc++.h>
using namespace std;

template<int D>bool cmp(const int a,const int b){ return D?a<b:a>b; }
bool (*fun[2])(const int,const int)={cmp<0>,cmp<1>};

int main(){
	int a[3] = {2,1,3},D;
	scanf("%d",&D);
	nth_element(a,a+1,a+3,fun[D]);
	printf("%d %d %d\n",a[0],a[1],a[2]);
}

C + + t x d y \mathrm{C++txdy}

发布了622 篇原创文章 · 获赞 91 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/qq_35950004/article/details/103945581