C++ If loop inside a for loop. Limits -


I have this code.

 for  (int j = 0; j and lt; = n; j ++) {xnew2 = j * (y + r2) / n; Ynew2 = PA ((((Y + R2) * (Y + R2) - (XNU2 * Xnew2), 0.5); The court's & lt; & Lt; "\ N (" << Xnew2 <<"<" "<< Ynew2 <; lt; & quot;); }   

I want to display all the values, but I also want to make a limit on the displayed values ​​to ensure that does not exceed ynew2 Any radius under 310 or -310 is 482.7mm, which is currently running.

How can I do this? I tried to put a if inside the loop, but it does not work and whatever I tried gave me only one value. Any help?

Try it out:

 for  (int j = 0; J & lt; = N + J ++) {Xnew2 = j * (Y + R2) / N; Ynew2 = PA ((((Y + R2) * (Y + R2) - (XNU2 * Xnew2), 0.5); If (stomach (Ynew2)> = 310) cout & lt; & Lt; "\ N (" & lt; & lt; Xnew2 << "," << Ynew2 <"lt; & quot;);"; }   

We use the abs function to get the full value of the Ynew2 variable, and compare it to 310 . If it is low

SidNote: You should avoid using \ n and std :: endl (or just endl if you have a announcement using the appropriate ).

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -