【发布时间】:2019-08-03 14:08:38
【问题描述】:
所以,我是在线竞争编程的新手,我遇到了一个代码,我在 for 循环中使用了 if else 语句。我想提高循环的速度,在做了一些研究之后,我遇到了 break 和 continue 语句。
所以我的问题是,使用 continue 是否真的提高了循环的速度。
代码:
int even_sum = 0;
for(int i=0;i<200;i++){
if(i%4 == 0){
even_sum +=i;
continue;
}else{
//do other stuff when sum of multiple of 4 is not calculated
}
}
【问题讨论】:
-
godbolt.org,应该生成相同的代码
标签: c++ if-statement continue