0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

複雑なfor文(基礎)

Last updated at Posted at 2021-01-17

複雑なfor文

❶初期化処理 ❷繰り返し条件 ❸繰り返し時処理の3つを工夫し、高度な繰り返しを実現

単に「◯◯回繰り返す」という単純な繰り返しではなく、下記のようにすれば少し高度な繰り返しが行える

//ループ変数を1からスタートする
for (int i = 1; i < 10; i++){...}

//ループ変数を2ずつ増やす
for (int i = 0; i < 10; i += 2){...}

//ループ変数を10から1ずつ1まで減らしていく
for (int i = 10; i > 0; i--){...}

//ループ変数を初期化しない
for (; i < 10; i++){...}

//繰り返し時の処理を行わない
for (int i = 0; i < 10;){...} 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?