Home > Back-end >  C language small white help bosses
C language small white help bosses

Time:10-08


Don't know why I always can't meet the conditions, hope bosses give correction method, if can optimize code is better, thank you
The code is as follows:
# include
Int main ()
{
Int M, N, I, sum, p, is, c, count, is1, i1, c1;
The scanf (" % d % d ", & amp; M, & amp; N);
Sum=0;
Count=0;
If (1 & lt;=M& & M=500){
For (I=M; i<=N; I++)
{
Is=1;
For (p=2; p{
C=I % p;
If (c==0)
{
Is=0;
break;
}
}
If (is==1)
{
Sum=sum + I;
Count++;
}
}
If (M==1 & amp; & N==500)
{
Printf (" % d % d ", the count - 1, sum - 1);
}
The else
{
Printf (" % d % d ", count, sum);
}
}
Else if (M==N)
{
Is1=1;
For (i1=2; I1 & lt; M; I1 + +)
{
C1=M % i1;
If (c1==0)
{
Is1=0;
break;
}
}
If (is1==1)
{
Printf (" d "1%, M);
}
The else
{
Printf (" 0 0 \ n ");
}
}
return 0;
}
  • Related