0.0分

2 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

下面就是你这个代码的执行情况:
1 2 3 
1 3 2 
2 1 3 
2 3 1 
3 1 2 
3 2 1 
1 2 4 
1 2 2 
2 1 4 
2 1 1 
2 1 2 
1 2 1 
1 3 4 
1 3 3 
3 1 4 
3 1 1 
3 1 3 
1 3 1 
2 3 4 
2 3 3 
3 2 4 
3 2 2 
3 2 3 
2 3 2 
-----------------
就这?这啥意思?误人子弟?你用你自己的代码通过了吗?现在有很多题解真是奇怪,自己过没过自己不知道吗?你把这个错误代码发上来,是让人找出错误吗?
2021-11-09 18:06:47
#include <iostream>
#include <string>
#include <algorithm> 
using namespace std;
int main()
{
	int s[4];
	for(int i=0;i<4;++i)
	{
		cin>>s[i];
	}
	do
	{
		cout<<s[0]<<s[1]<<s[2]<<' '<<endl;
	 }while(next_permutation(s,s+3));
	 swap(s[2],s[3]);
	 do
	{
		cout<<s[0]<<s[1]<<s[2]<<' '<<endl;
	 }while(next_permutation(s,s+3));
	 swap(s[1],s[3]);
	 do
	{
		cout<<s[0]<<s[1]<<s[2]<<' '<<endl;
	 }while(next_permutation(s,s+3));
	 swap(s[0],s[3]);
	 do
	{
		cout<<s[0]<<s[1]<<s[2]<<' '<<endl;
	 }while(next_permutation(s,s+3));
	 
}
2020-08-01 09:38:19
#include<iostream>
using namespace std;
#include <cmath>
#include <iomanip>
int main()
{    
    int a[4];
    cin>>a[1]>>a[2]>>a[3]>>a[4];
    for(int x=4;x>=1;x--){
        for(int i=1;i<=4;i++){
            if(i!=x)
                for(int j=1;j<=4;j++){
                    if(j!=x)
                        for(int m=1;m<=4;m++){
                            if(m!=x)
                                if((i!=j) &&(i!=m)&&(j!=m))
                                    cout<<a[i]<<" "<<a[j]<<" "<<a[m]<<endl;
                        }
                }
        }    
    }
}
2020-08-01 09:37:46
  • «
  • 1
  • »