HDOJ配列2 1716

1974 ワード

配列2
Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5315    Accepted Submission(s): 2029
Problem Description
Rayはまた数字の列に興味を持った.
既存の4枚のカードは、この4枚のカードで多くの異なる4桁を並べることができ、これらの4桁を小さい順に出力することが要求されている.
 
Input
各グループのデータが1行を占め、4枚のカードの数字(0<=数字<=9)を表し、4枚のカードが0であれば入力が終了する.
 
Output
各カードグループに対して、この4枚のカードからなるすべての4桁を小さい順に出力し、千桁の数字は同じ行で、同じ行の4桁の間にスペースで区切られます.
各グループの出力データ間には1行が空で、最後のグループのデータの後ろには空の行がありません.
 
Sample Input

   
   
   
   
1 2 3 4 1 1 2 3 0 1 2 3 0 0 0 0

 
Sample Output

   
   
   
   
1234 1243 1324 1342 1423 1432 2134 2143 2314 2341 2413 2431 3124 3142 3214 3241 3412 3421 4123 4132 4213 4231 4312 4321 1123 1132 1213 1231 1312 1321 2113 2131 2311 3112 3121 3211 1023 1032 1203 1230 1302 1320 2013 2031 2103 2130 2301 2310 3012 3021 3102 3120 3201 3210

 
Source
2007省試合合宿チーム練習試合(2)
 
Recommend
lcy   |   We have carefully selected several similar problems for you:   1715  1719  1717  1521  1112 
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a[10];
	int t=0;
	while(scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])!=EOF){
		if(a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0)
		break;
		int num=a[0];
		int x=0;
		if(t)printf("
"); t=1; do{ if(a[0]==0)continue; if(x==1&&a[0]==num)printf(" "); if(num!=0&&a[0]!=num)printf("
"); for(int i=0;i<4;i++){ printf("%d",a[i]); } x=1; num=a[0]; } while(next_permutation(a,a+4)); printf("
"); } return 0; }