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