2016-12-04 3 views

答えて

1

言語を指定していないため、ここにいくつかのJavaがあります。

アルゴリズムは依然として適用されます。

// the modifier to apply 
int modifier = 1; 

// min and max values 
int maxValue = 10; 
int minValue = -10; 

// the value of the count 
int count = 0; 

// loop forever 
while (true) { 

    // it higher then max or below min 
    if (count >= maxValue || count <= minValue) { 

     // invert the modifier 
     modifier = (modifier * -1); 
    } 

    // add modifier to count 
    count += modifier; 

    // use it 
    doSomethingWith(count); 
} 

この意志、

    • スタート0
    • までカウントダウン-10
    • から
    • 回数にカウントアップ繰り返す
  • 関連する問題