0

for an assignment I was given java pseudocode that included lines:

do for i = 0...j-1

do if i = 0 and j = 1

for k = 0....i-1
  do q <- l[k,i] + dist(p[k],p[j])

since the only use for "do" in java that I am aware of in java is do-while loops, (which I am not great with, preferring to stick to for loops), I don't really know how to translate this into java.

jokeSlayer94
  • 143
  • 1
  • 9
  • 4
    *"...what do these lines of pseudocode mean?"* That the person giving you the assignment was using ***pseudocode*** (literally: "fake code"), not Java syntax? – T.J. Crowder May 08 '15 at 21:31
  • Comparing any pseudo code to any specific language syntax should be hard to do as at the time of writing said pseudo code the language used to implement it need not be known. – ChiefTwoPencils May 08 '15 at 21:34
  • The `do` in this context just means that you have to do what's followed by it. Not the keyword in Java. – Bubletan May 08 '15 at 21:36
  • god I feel stupid. Every time I ask a question on this site, its either to broad and gets downvoted, or its a stupid question that I figure out the answer too after I think about it for a minute. – jokeSlayer94 May 08 '15 at 21:40

1 Answers1

0

Not enough references in your question but i think you can start with :

int i, j=10;
for(i = 0; i < j; i++){ //do for i = 0... j-1
    if( i== 0 && j == 1){ // do if i =0 and j = 1
    }
    for(int k = 0; k<i; k++){ //for k = 0....i-1
         //not sure what do you mean by do q <- l[k,i] + dist(p[k],p[j])
    }
}
DoubleMa
  • 368
  • 1
  • 8