? Four given two positive integers a, b, find out between these two Numbers (including) all meet the following conditions:
? 1. The four digits are prime Numbers;
? 2. The one thousand number and one hundred number of double-digit AB is a completely square number;
? 3. Ten digits with double-digit composed of bits digital CD is a completely square number
# include
Int main ()
{
Int a, b, c=0, I, j, p1, p2, n=0;
The scanf (" % d % d ", & amp; A, & amp; B);
For (I=a; i<=b; I++)
{
For (j=2; J{
If (I % j==0)
{
C=1;
break;
}
The else
C=c;
}
If (c==0)
{
P1=I/100;
The p2=I % 100;
If (p1==16 | | p1==25 | | p1==36 | | p1==49 | | p1==64 | | p1==81)
{
If (p2==1 | | p2==4 | | p2==9 | | p2==16 | | p2==25 | | p2==36 | | p2==49 | | p2==64 | | p2==81)
{
n=n+1;
Printf (" % d \ n ", I);
}
}
}
}
Printf (" % d ", n);
}
Why my code at run time is always not the if (c==0) the inside, who can teach, a little confused, CodePudding user response:
# include
Int main ()
{
Int a, b, c=0, I, j, p1, p2, n=0;
The scanf (" % d % d ", & amp; A, & amp; B);
For (I=a; i<=b; I++)
{
For (j=2; J{
If (I % j==0)
{
C=1;
break;
}
The else
C=c;
}
If (c==0)
{
P1=I/100;
The p2=I % 100;
If (p1==16 | | p1==25 | | p1==36 | | p1==49 | | p1==64 | | p1==81)
{
If (p2==1 | | p2==4 | | p2==9 | | p2==16 | | p2==25 | | p2==36 | | p2==49 | | p2==64 | | p2==81)
{
n=n+1;
Printf (" % d \ n ", I);
}
}
}
C=0;//need to initialize
}
Printf (" % d ", n);
}
For your reference ~
Need to c the re-initialization
CodePudding user response:
/* redundant code ~
The else
C=c;
*/
This part is redundant code, suggest delete ~
Or here to is as follows:
The else
c=0;
CodePudding user response: