expressions like Abcde/fghij = N (c-language Solver)

Source: Internet
Author: User

• Title: Enter positive integer n to output all expressions, such as abcde/fghij=n, in order from small to large, where a~j happens to be an arrangement of the digital 0~9, 2<=n<=79 input: 62 output: 79546/01283=62 94736/01528= 62
1#include <stdio.h>2 3 intMain ()4 {5     intN,x,y,temp;//a[10]={0};6     intI,j,flag;7scanf"%d",&n);8      for(x=12345; x<=98765; x + +)9     {Ten         inta[Ten]={0}; OneFlag =1; Atemp =x; -          -     //if (x%n! = 0)//do not use this sentence array A to re-initialize all!  the     //continue; -      -         if(x%n==0)//record the individual bits of y -         { +          -y = x/N; +              for(i=4; i>=0; i--) A             { atA[i] = y%Ten; -y = y/Ten; -             } -         } -          -          for(i=9; i>=5; i--)//record the individual bits of x in         { -A[i] = temp%Ten; totemp = temp/Ten; +              -         } the          *          for(i=0;i<9; i++)//Judging there is no duplication of $         {Panax Notoginseng              for(j=i+1; j<=9; j + +) -             { the                 if(A[i] = =A[j]) +                 { AFlag =0; the                      Break; +                 } -             } $             if(Flag = =0) $                  Break; -         } -          the         if(flag==1)//Print -         {Wuyi              for(i=5; i<=9; i++) theprintf"%d", A[i]); -printf"/"); Wu              for(i=0;i<5; i++) -printf"%d", A[i]); Aboutprintf"=%d\n", n); $         }     -     } -     return 0; -}

expressions like Abcde/fghij = N (c-language Solver)

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.