下面就是你这个代码的执行情况: 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 ----------------- 就这?这啥意思?误人子弟?你用你自己的代码通过了吗?现在有很多题解真是奇怪,自己过没过自己不知道吗?你把这个错误代码发上来,是让人找出错误吗?
#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)); }
#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; } } } } }
bilibili用户 2020-08-01 09:38:04 |
直接stl不香码
大神老白 (C语言代码)浏览:611 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:572 |
妹子杀手的故事 (C语言代码)浏览:1234 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)万恶的long long浏览:880 |
C语言训练-数字母 (C语言代码)浏览:649 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)浏览:549 |
用筛法求之N内的素数。 (C语言代码)浏览:652 |
三角形 (C语言代码)浏览:914 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:707 |
汽水瓶 (C语言代码)浏览:536 |
余小C 2022-03-31 08:59:02 |
傻逼傻逼滚,不看就滚,nmsl
余小C 2022-03-31 08:59:27 |
自己搞错懂不懂
sor 2022-05-10 18:17:16 |
@786909783 nqjsl,nqjsyhkb,沙薄衣。全家沙薄衣,nm连话都不会说了吧???
sor 2022-05-10 18:17:52 |
@786909783 搞不懂你马 薄衣是圆的还是方的吧???好像是方的
sor 2022-05-10 18:21:56 |
@786909783 就你这脑子还编程???你马小时候是不是把胎盘留下了,把你扔了???
sor 2022-05-10 18:22:48 |
@786909783 一道题,对就是对,错就是错了。你马的沙伯衣,连这都不明白吗?纯沙笔