break与continue的邂逅,有时令人眼花缭乱~
break运行效果:
for (int i = 0 ; i < n ; i++){
cin >> a[i];
if (a[i] == 1) break;
cout << a[i];
}
输入
2 3 4 5 1 6
输出
2 3 4 5
continue运行效果:
for (int i = 0 ; i < n ; i++){
cin >> a[i];
if (a[i] == 1) continue;
cout << a[i];
}
输入
2 3 4 5 1 6
输出
2 3 4 5 6
小编知道的区别zi有这个,各位大佬有没有其他区别~