Home > Back-end >  To solve the program
To solve the program

Time:09-16

CodePudding user response:

Using the exhaustive method, a simple one,

CodePudding user response:

 for (int I=1000; I & lt; 9999; I++) 
for (int j=1; J & lt; 9. J++) {
Int a, b, c, d;
A=I % 10;
B=(I/10) % 10;
C=(I/100) % 10;
D=(I/1000);
If (a==b | | a==c | | a==d | |
B==c | | b==d | |
C==d)
continue;
If (I * j==a + b * 1000 * 100 * 10 + c + d)
{
Cout & lt; }
}

CodePudding user response:

 int a, b, c, d; 
D=I % 10;
C=(I/10) % 10;
B=(I/100) % 10;
A=(I/1000);

CodePudding user response:

To solve the
Given a binary tree, a request sequence output of the binary tree node values,
Input format:
The first line contains an integer n (n<=50), said the tree with n vertices, numbered from 1 to n, respectively, in the number of 1 as the root node,
Line 2 to the n + 1 line, in turn, said node to node n 1, the first I + 1 (1=& lt; i<=n) line with three integers, respectively represent the node value of node I, left child node number and the right child node number, if the node I no right child nodes or left child node, then replace with 0,
The output format:
Order after the binary tree traversal of all nodes value
Sample input:
6
2, 3, 100
5-10 6
999 4 0
7 0 0
120 0 0
1 0 0
Sample output: 120-1-10 of 7, 999, 100

CodePudding user response:

 # include & lt; Stdio. H> 
Int main (int arg c, char * * argv)
{
Int a, b, c, d, e;
For (a=1; a<=9; {+)
for ( b=0; B<=9; B++) {
If (a!=b) {
For (c=0; C<=9; C + +) {
If (b!=c & amp; & b! {
=a)For (d=1; D<=9; D++) {
If (d!=b & amp; & d!=c & amp; & d!
=a)For (e=1; E<=9; E++)
If (e!=a & amp; & e!=b & amp; & e!=c & amp; & e!=d)
{
If ((a + b * 1000 * 100 * 10 + c + d) * e==(d + c * 100 * 1000 * 10 + a + b))
Printf (" % d % d % d % d * % d=% d % d % d % d \ n ", a, b, c, d, e, d, c, b, a);
}
}
}
}
}
}
}
}

A program very smelly, but right.

CodePudding user response:

To solve the
Given a binary tree, a request sequence output of the binary tree node values,
Input format:
The first line contains an integer n (n<=50), said the tree with n vertices, numbered from 1 to n, respectively, in the number of 1 as the root node,
Line 2 to the n + 1 line, in turn, said node to node n 1, the first I + 1 (1=& lt; i<=n) line with three integers, respectively represent the node value of node I, left child node number and the right child node number, if the node I no right child nodes or left child node, then replace with 0,
The output format:
Order after the binary tree traversal of all nodes value
Sample input:
6
2, 3, 100
5-10 6
999 4 0
7 0 0
120 0 0
1 0 0
Sample output: 120-1-10 of 7, 999, 100

CodePudding user response:

refer to the second floor truth is right or wrong response:
 for (int I=1000; I & lt; 9999; I++) 
for (int j=1; J & lt; 9. J++) {
Int a, b, c, d;
A=I % 10;
B=(I/10) % 10;
C=(I/100) % 10;
D=(I/1000);
If (a==b | | a==c | | a==d | |
B==c | | b==d | |
C==d)
continue;
If (I * j==a + b * 1000 * 100 * 10 + c + d)
{
Cout & lt; }
}

Can write on the ground floor, I improve the
 
For (int I=1000; I & lt; 9999; I++)
{
for (int j=1; J & lt; 10; J++)
{
Int a, b, c, d;
A=I % 10;
B=(I/10) % 10;
C=(I/100) % 10;
D=I/1000;
If (a==b | | a==c | | a==d | |
B==c | | b==d | |
C==d)
continue;
If (I * j==a + b * 1000 * 100 * 10 + c + d)
{
Cout & lt;
  • Related