Home > Back-end >  Online etc.! Be urgent!
Online etc.! Be urgent!

Time:03-21

Enter a number of positive integers, when the input zero or negative end, need this in a number of positive integer calculation and the even number and all even number,

CodePudding user response:

Reference:
 # include 

Int main ()
{
Int n, CNT=0, sum=0;
While (1) {
The scanf (" % d ", & amp; n);
If (n & lt;=0) break;
{if (n % 2==0)
Cnt++;
The sum +=n;
}
}
Printf (" CNT=% d, the sum=% d \ n ", CNT, sum);

return 0;
}

CodePudding user response:

This should be a very basic question, it is recommended that the original poster is more at ordinary times, reading more, at least your online search tone can also be improved?

 while (the scanf (" % d ", & amp; N)==1 & amp; & N & gt; 0 {
If (n % 2)
continue;
Cnt++;
The sum +=n;

}

Make some changes, break into the continue, more than one way

CodePudding user response:

I don't liquid, follow to learn
  • Related