Search for a pair of tears on the road, get started with search questions, get started with tears on the road
Although the first independent search question is very difficult, it is the beginning, and I wish myself an early solution.
No difficulty. Note only space control and line feed.
#include <stdio.h>#include <stdlib.h>#include <string.h>int flag[10], a[5], k1, k2, k;bool found(int yu[]){ int i; for(i = 0; i < 10; i++) { if(yu[i]!=0) return 0; } return 1;}void ax(int be){ int i, j; if(found(flag)) { if(a[0]!=k1&&k2!=0) { printf("\n"); } if(a[0]==k1) printf(" "); for(i = 0; i < 4; i++) printf("%d",a[i]); k1 = a[0]; k2 = 1; return; } for(i = be; i < 4; i++) { for(j = 0; j < 10; j++) { if(i==0&&j==0) continue; if(flag[j]) { a[i] = j; flag[j]--; ax(i + 1); flag[j]++; } } }}int main(){ int i, x, y, m, n; while(scanf("%d%d%d%d", &x, &y, &m, &n),x!=0||y!=0||m!=0||n!=0) { if(k != 0) printf("\n"); k = 1; k1 = 10; k2 = 0; memset(flag,0,sizeof(flag)); memset(a,0,sizeof(a)); flag[x]++; flag[y]++; flag[n]++; flag[m]++; ax(0); printf("\n"); } return 0;}
--- Restore content end ---