给定不超过6的正整数A,考虑从A开始的连续4个数字。请输出所有由它们组成的无重复数字的3位数。
输入格式:
输入在一行中给出A。
输出格式:
输出满足条件的的3位数,要求从小到大,每行6个整数。整数间以空格分隔,但行末不能有多余空格。
输入样例:
2
输出样例:
234 235 243 245 253 254 324 325 342 345 352 354 423 425 432 435 452 453 523 524 532 534 542 543
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,i,a[10],cnt=1,j,k;
scanf("%d",&n);
memset(a,0,sizeof(a));
for(i=0;i<4;i++){
a[i]=n+i;
}
int s;
do{
s=a[0]*100+a[1]*10+a[2];
if(cnt%6!=0){
printf("%d ",s);
}else{
printf("%d/n",s);
}
cnt++;
}while(next_permutation(a,a+4));
return 0;
}
原创文章,作者:Carrie001128,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/245441.html