弱校联萌十一大决战之背水一战A A Big Dinner

As is known to all, an ACM team consists of three members and to know more about each others, they often go to a restaurant to have a big dinner.

Each member ordered himself only one dish, and waited for it. However, the restaurant serves in a strange way. They cooked the meal in a random order. Besides, if some same dishes appear consecutively, the cooks will cook the dishes at the same time.

Given the ordered three dishes, can you output every possible order the restaurant severed.

Input


The first line of the input is T(1 <= T <= 100), which stands for the number of test cases you need to solve.

For each case, there are three integers(the integers are all positive and less than 10) in the single line, which stand for the dish ID for each person.

Output


Every case contains one line with three integer standing for the kinds of ordered dishes.

For every test case, you should output "Case #t:" in the first line, where t indicates the case number and counts from 1. Then output all the possible order the restaurant can serve in the ascending order.

Sample Input

2
2 1 2
1 7 5

Sample Output

Case #1:
1 2 2
2 1 2
2 2 1
Case #2:
1 5 7
1 7 5
5 1 7
5 7 1
7 1 5
7 5 1


这个题考的全排列 而且是升序的 自己开始还想傻乎乎的枚举各种情况 还把升序这个条件给忘了

其实之前自己就用过 next_permutation 1027Ignatius and the Princess II 到底还不是自己做出来的 印象不深啊 

自动去重的功能好强大 ╭(╯^╰)╮

#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int A[3];
void show(){
	for(int i=0;i<2;i++){
		printf("%d ",A[i]);
	}
	printf("%d\n",A[2]);
}
int main(){
    int n,t=1;
    cin>>n;
    while(n--){
        for(int i=0;i<3;i++) scanf("%d",&A[i]);
        sort(A,A+3);
        printf("Case #%d:\n",t++);
        do{
		   show();
	    }while(next_permutation(A,A+3));
    }
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值