Home > Back-end >  A 29 cm long ruler, allowing only engraved on it seven scale. If you want to use it the energy out v
A 29 cm long ruler, allowing only engraved on it seven scale. If you want to use it the energy out v

Time:11-20

Thank you bosses!!!!!!!!!!!!!!!!

CodePudding user response:

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
1 1 1 1 1 1 1 1 1

 
//a 29 cm long ruler, allowing only engraved on it seven scale, if you want to use it the energy out various the whole length of 1 ~ 29 cm, scale should be how to choose?
Void RulerResult (void)
{
Struct
{
Bool test;
Int maxID;
Int minID;
}
The result [29].

Int mark [9];
Mark [0]=0;
Mark [8]=29;

For (int a=1; A. & lt; 23. + + a)
{
For (int b=a + 1; B & lt; 24. + a + b)
{
For (int c=b + 1; C & lt; 25. + + c)
{
For (int d=c + 1; D & lt; 26. + + d)
{
For (int e=d + 1; E & lt; 27. + + e)
{
For (int f=e + 1; F & lt; 28; + + f)
{
For (int g=f + 1; G & lt; 29. + + g)
{
Mark [1]=a;
Mark [2]=b;
Mark [3]=c;
Mark [4]=d;
Mark [5]=e;
Mark [6]=f;
Mark [7]=g;

Memset (result, false, sizeof (result);

For (int I=0; i <8; + + I)
{
For (int j=I + 1; J & lt; 9. + + j)
{
Int id=mark [j] - mark [I] 1.
Result [id]. Test=true;
Result [id]. MaxID=mark [j];
Result [id]. MinID=mark [I];
}
}

Bool allTest=true;
For (int I=0; i <29. + + I)
{
If (result [I]. Test)
continue;

AllTest=false;
break;
}

If (allTest)
{
For (int I=0; i <9. + + I)
{
Printf (" % d ", mark [I]);
}

Printf (" \ r \ n ");

For (int I=0; i <29. + + I)
{
Printf (" % d=% d, % d \ r \ n ", I + 1, the result [I] maxID, result [I] minID);
}

return;
}
}
}
}
}
}
}
}
}


0 1 2 14 of 18 21 and 24 and 29
1=2-1
2=29-27
3=27-24
4=18 to 14
5=29-24
6=27-21
7=21-14
8=29-21
9=27-18
10=24-14
11=29-18
12=14-2
13=27-14
14=14-0
15=29-14
16=18-2
17=18-1
18=18-0
19=21-2
20=21-1
21=21-0
22=24-2
23=24-1
24=24-0
25=27-2
26=27-1
27=29-2
28=29-1
29=29-0
Please press any key to continue...

CodePudding user response:

For reference only, the code is as follows:
 # include & lt; stdio.h> 

Int main (void)
{
Int flag, mark [9];
Int a, b, c, d, e, f, g;
Int I, j;
int count=0;

Mark [0]=0;
Mark [8]=29;

for(a=1; a<23. +)
{
Mark [1]=a;
For (a + b=1; B<24. B++)
{
Mark [2]=b;
For (c=b + 1; C<25. C + +)
{
Mark [3]=c;
For (d=c + 1; D<26. D++)
{
Mark [4]=d;
For (e=d + 1; E<27. E++)
{
Mark [5]=e;
For (f=e + 1; F<28; F++)
{
Mark [6]=f;
For (g=f + 1; G<29. G + +)
{
Mark [7]=g;

flag=1;

for(i=0; i<8; I++)
{
for(j=i+1; J<9. J++)
{
Flag |=(1 & lt; <- mark (mark [j] [I]));
}
}

If (flag==0 x3fffffff)
{
Printf (" NO. % d: \ \ t t % d % d % d \ \ t t t % d % d \ \ t t % d % d \ \ t \ n ", + + count, a, b, c, d, e, f, g);
}
}
}
}
}
}
}
}

return 0;
}


The results are as follows:
 E: \ Workspace> TCC - run the demo. C 
NO. 1:1 2 14 of 18 21 and 24 and 27
NO. 2:1 3 6 13 20 to 24, 28
NO. 3:1 4 10 16 22 and 24 and 27
NO. 4:1 5 September 16, 23, 26, 28
NO. 5:2 5 July 13 19 25 to 28
NO. 6:2, 5, 8, 11 15 27 to 28
  • Related