用数组b记录数组a的下标
然后使用next_permutation()函数得到数组a的元素顺序的全排列
参考资料:https://blog.csdn.net/qian2213762498/article/details/79683905
参考代码
#include<iostream> #include<algorithm> using namespace std; int main() { int n, m; int a[4]; int b[4] = {0,1,2,3}; cin >> n; while(n --) { for (int i = 0; i < 4; i ++) cin >> a[i]; m = 1; //m用于记录当前列数 do { for (int i = 0; i < 4; i ++) cout << a[b[i]]; if(m%6) cout << " "; else cout << endl; m ++; } while (next_permutation(b,b+4)); cout << endl;; } return 0; }
0.0分
1 人评分
2005年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:822 |
点我有惊喜!你懂得!浏览:1336 |
C语言程序设计教程(第三版)课后习题12.1 (C语言代码)浏览:978 |
【回文数(二)】 (C++代码)浏览:865 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:561 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:1195 |
【蟠桃记】 (C语言代码)浏览:664 |
DNA (C语言代码)浏览:540 |
杨辉三角 (C语言代码)浏览:484 |
C二级辅导-等差数列 (C语言代码)浏览:694 |