How to add a repeat loop (for) when needed

0

I have a program where there are three parameters. So:

These three parameters are positions within m_aluno[w_i][w_j][w_k]); , where w_i can receive a position informed by the user or not and this is for w_j and w_k also; My problem is where, if you enter a value for w_i and then w_j and w_k are empty, only w_j and w_k that it will start in 0 o will be iterated. w_i must stay in the informed position!

My case is, "I want to add a repeat loop only when I need it. How do I do this?"

I played JSFiddle with all as condições for better visualization (it was supposed to work, but I can not edit to execute the function first).

Code I want to decrease

So there are três for's :

for (w_i=0; w_i<w_ii; w_i++) //primeiro
     {
     for (w_j=0; w_j<w_jj; w_j++) //segundo 
         {
         for (w_k=0; w_k<w_kk; w_k++) //terceiro
             {
  • If w_i does not start in 0 the first for has to disappear.
  • If w_j does not start in 0 second for has to disappear.
  • If w_k does not start in% with% third 0 has to disappear.

The for will not start in 0 unless you enter some value for them.

    
asked by anonymous 20.11.2014 / 13:33

0 answers