#include<stdio.h> #include<iostream> #include<string> #include<algorithm> #include<cmath> using namespace std; int a[4]; bool vis[4]; int ans[4]; int cnt; void dfs(int step) { if (step == 4) { cnt++; for (int i = 0; i < 4; i++) cout << ans[i]; cout << " "; if (cnt == 6) { cnt = 0; cout << endl; } return; } for (int i = 0; i < 4; i++) { if (!vis[i]) { ans[step] = a[i]; vis[i] = true; dfs(step + 1); vis[i] = false; } } } int main() { int n; cin >> n; while (n--) { for (int i = 0; i < 4; i++) cin >> a[i]; dfs(0); cout << endl; } return 0; }
0.0分
0 人评分
C二级辅导-进制转换 (C语言代码)浏览:615 |
数列排序 (C语言代码)浏览:835 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:638 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:634 |
简单的a+b (C语言代码)浏览:419 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:324 |
DNA (C语言代码)浏览:741 |
1197求助浏览:629 |
1218题求大神帮忙看看怎么不能过浏览:698 |
检查金币 (C语言代码)浏览:1415 |