Search for a pair of tears on the road, get started with search questions, get started with tears on the road

Source: Internet
Author: User

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 ---

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.