XIZOE


私信TA

用户名:903917066

访问量:4231

签 名:

等  级
排  名 315
经  验 5363
参赛次数 1
文章发表 25
年  龄 18
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

用数组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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区