无涯教程-D语言 - continue 语句函数

38 阅读1分钟

D编程语言中的CONTINUE语句的工作方式有点像break语句,但是,Continue并不强制终止,而是强制进行循环的下一次迭代,跳过其间代码。

continue - 语法

D中CONTINUE语句语法如下所示:-

continue;

continue - 流程图

D continue statement

continue - 示例

import std.stdio;

int main () { /* 局部变量定义 */ int a=10;

/* 做循环执行 / do { if( a == 15) { / 跳过循环 */ a=a + 1; continue; } writefln("value of a: %d", a); a++;

} while( a < 20 );

return 0; }

编译并执行上述代码时,将生成以下结果-

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19

参考链接

www.learnfk.com/d-programmi…