国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

ChucK初步(6)

2019-11-14 09:36:16
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

control structures

if / elsewhile & do…while…untilforbreak / continue

Control Structures

ChucK includes standard control structures similar to those in most PRogramming languages. A condition (of type ‘int’) is evaluated and then a proceeding block is potentially executed. Blocks are separated either by semicolons(分號(hào)) or by curly brackets(花括號(hào)).

if / else

The if statement executes a block if the condition is evaluated as non-zero.

if( condition ){ // insert code here}

In the above code, condition is any expression that evaluates to an int. (條件是一個(gè)值為整數(shù)的表達(dá)式)

The else statement(聲明) can be put after the if block to handle the case where the condition evaluates(求值) to 0.

if( condition ){ // your code here}else{ // your other code here}

If statements can be nested(嵌套).

while & do…while…

// here is an infinite loopwhile( true ){ // your code loops forever! // (sometimes this is desirable because we can create // infinite time loops this way, and because we have // concurrency)} do { // your code executes here at least once} while( condition );

A few more points:

while statements can be nested.see break/continue for additional(附加的) control over your loops

until

The until statement is the opposite of while, semantically(語(yǔ)義地). A until loop repeatedly executes the body until the condition evaluates as non-zero.

// an infinite loopuntil( false ){ // your great code loops forever!}

A few more points:

while statements can be nested.see break/continue for additional(附加的) control over your loops

for

A loop that iterates(迭代) a given number of times.(迭代給定次數(shù)) A temporary(暫時(shí)的) variable(變量) is declared that keeps track(跟蹤) of the current index and is evaluated and incremented at each iteration(迭代).

// for loopfor( 0 => int foo; foo < 4 ; foo++ ){ // debug-print value of 'foo' <<<foo>>>;}

break / continue

Break allows the program flow to jump out of a loop.

// infinite loopwhile( 1 ){ if( condition ) break;}

Continue allows a loop to continue looping but not to execute(實(shí)行) the rest of the block for the iteration where continue was executed.(跳過(guò)當(dāng)前的循環(huán))

// another infinite loopwhile( 1 ){ // check condition if( condition ) continue; // some great code that may get skipped (if continue is taken)}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 富源县| 西安市| 丰镇市| 新野县| 广饶县| 磐石市| 临朐县| 许昌市| 连州市| 肃宁县| 游戏| 太仆寺旗| 龙胜| 鄂尔多斯市| 沁水县| 鹤庆县| 哈尔滨市| 正镶白旗| 婺源县| 平塘县| 阆中市| 渝北区| 鹤峰县| 莱州市| 环江| 惠来县| 宜兰市| 肥城市| 怀宁县| 嘉义市| 涞源县| 山东省| 桐城市| 游戏| 台东市| 囊谦县| 恩施市| 天柱县| 攀枝花市| 卓资县| 绍兴县|