C language · Guess the formula

Source: Internet
Author: User

Title: The equation of Guess

Look at the following equation:

--x--=--x---

It means: two double-digit multiplication equals a two-digit number multiplied by a three-digit number. If there are no qualifying conditions, there are many examples.

However, the current limit is: The 9 blocks, representing the 1~9 9 numbers, does not contain 0. Each number from 1 to 9 in the calculation appears and appears only once!

For example: "x" = x 158 x "x" = 138 x x 186 ...

Please program, output all possible situations!

Note: The two multiplier on the left swaps the same scheme, do not repeat the output!

Candidates are required to write all functions in a file. After debugging, deposit with the candidate folder corresponding to the "answer. txt" in the title can be. The relevant engineering documents should not be copied into. For programming topics, the player is asked to give a solution that conforms to the ANSI C standard, cannot use C + + features, and cannot use hardware-related or operating-system related APIs such as drawing, interrupt invocation, and so on.

1 #include <stdio.h>2#include <string.h>3 BOOLuse[Ten];//Access Tag Array4 inta[Ten];//determine if the product of a and B has occurred5 intYin1,yin2,yin3,yin4;6 intCount=0;7 voidDfsintbegin) {  8     if(begin==Ten){9yin1=a[1]*Ten+a[2];Tenyin2=a[3]*Ten+a[4]; Oneyin3=a[5]*Ten+a[6]; Ayin4=a[7]* -+a[8]*Ten+a[9]; -         if((YIN1*YIN2==YIN3*YIN4) && yin1<yin2) { -count++; theprintf"%2d*%2d =%2d*%3d\n", YIN1,YIN2,YIN3,YIN4); -         } -         return;  -     }   +      for(intI=1; i<=9; i++){ -         if(!Use[i]) { +Use[i] =true; Aa[begin]=i; atDFS (begin+1); -Use[i] =false; -         } -     }   - }   - intMain () { inmemset (use,false,sizeof(use)); -Dfs1); toprintf"\ n There are%d of them.", count); +     return 0; -}

C language · Guess the formula

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.