てきとうなメモ

本の感想とか技術メモとか

breakとcontinue

break/continueがなかったらwhileとifだけでどう書けるかなとかちょっと考えてた

while (condA) {
  statementA;
  if (condB) {
     break;
  }
  statementB;
}

flag = true;
while (condA && flag) {
  statementA;
  if (condB) {
     flag = false;
  }
  else {
    statementB;
  }
}

と書けばよいし、

while (condA) {
  statementA;
  if (condB) {
    continue;
  }
  statementB;
}

while (condA) {
  statementA;
  if (condB) {
  }
  else {
    statementB;
  }
}

と書けば良いか