c/c++ | c# | java | |
循环 |
for(init;condition;increment){ } while(condition){ } do{ }while(condition); break; //跳出循环 continue; //跳过一次循环 |
for(init;condition;increment){ } foreach(datatype variable in array){ } while(condition){ } do{ }while(condition); break; //跳出循环 continue; //跳过一次循环 |
for(init;condition;increment){ } while(condition){ } do{ }while(condition); for(datatype variable : array){ } break; //跳出循环 continue; //跳过一次循环
|
判断 |
if(condition){ } else{ } switch(expression) { case option : statements; break; //可选,跳出判断 case option : statements; break; //可选 default : //可选 statements; } |
if(condition){ } else{ } switch(expression) { case option : statements; break; //可选,跳出判断 case option : statements; break; //可选 default : //可选 statements; } |
if(condition){ } else{ } switch(expression) { case option : statements; break; //可选,跳出判断 case option : statements; break; //可选 default : //可选 statements; } |
python | matlab | ||
循环 |
while condition: statements for variable in sequence statements break; //跳出循环 continue; //跳过一次循环 pass; //不做任何事情,一般用做占位语句,为了保持程序结构的完整性 |
while(condition) statements; end for index = array for index = initval:endval for index = initval:step:endval break; //跳出循环 continue; //跳过一次循环 | |
判断 |
|
if condition elseif condition statements; elseif condition statements; else statements; switch expression case option statements case option statements otherwise statements end |