C++入门学习(二十七)跳转语句—break语句

1、与switch语句联合使用

C++入门学习(二十三)选择结构-switch语句-CSDN博客

#include   
#include 
using namespace std;
  
int main() {  
 
int number;
 
cout<<"请为《斗萝大路》打星(1~5※):" <>number;
switch (number) {
	case 1:
		cout<<"*"<

如果没有break,会产生怎样的效果呢?我将上述代码中的break都删除一了,看一下结果吧: 

C++入门学习(二十七)跳转语句—break语句_第1张图片

2、与for循环结合起来

C++入门学习(二十六)for循环-CSDN博客

#include   
using namespace std;
int main() {  
    for (int i = 1; i <= 10; i++) {  
         if (i==6)
		{
			cout<<"666"<

C++入门学习(二十七)跳转语句—break语句_第2张图片

你可能感兴趣的:(C++入门,前端,javascript,数据库)