Home > Back-end >  Java programming, calculate the odd and within 100
Java programming, calculate the odd and within 100

Time:10-10

Have to conform to the requirements, there is a great god know how to write this

CodePudding user response:

Int result=0
For I=0 I <100 i++
If (I& 1==0)
continue;
The result +=I

CodePudding user response:

reference 1st floor with ah response:
int result=0
For I=0 I <100 i++
if (I& 1==0)
continue;
The result +=I

What is the meaning of this

CodePudding user response:

 public static void main (String [] args) {

int sum=0;
For (int I=1; I & lt;=99; I++) {
I % 2==0 sum +=? Zero: I;
}
System. The out. Println (sum);
}

CodePudding user response:

With a 1st floor operations (his code lot of using Chinese characters, pay attention to the line, can also learn the related knowledge), you will need to traverse in every times the number of converted to binary, compared with the true value of the bottom 1, if you don't understand, you can see this, this is easier to understand, (- your last post junction, I will also help you to this). Also, it is best to their written some code, the code is the foundation of knowledge, also be the basis of many programming languages, or better their learning, not a post to every time, let others help you to do the homework
 
int sum=0;
for(int i=1; i<100; I++) {
If (I % 2==0) {
continue;
}
The sum +=I;
}
System. Out. Println (" sum: "+ sum);
  • Related