#include<iostream>
using namespace std;
int main()
{
//for语句满足循环条件,执行语句
//for(起始表达式;条件表达式;末尾循环体){循环语句;}
for (int i = 0; i < 10; i++)
{
cout << i << endl;
}
//敲桌子
for (int a = 0; a <= 100; a++ )
{
if (a % 7 == 0 || a % 10 == 7||a/10 == 7)
{
cout << "敲桌子" << endl;
}
else
{
cout << a << endl;
}
}
//嵌套循环实现星图
//外层执行一次,内层执行一周
for (int c = 0; c < 10; c++)
{
for (int f = 0; f <10; f++)
{
cout << "* " ;
}
cout << endl;//endl相当于结束该行打印
}
//九九乘法表
for (int i = 1; i < 10; i++)
{
for (int j = 1; j < 10; j++)
{
if (j <= i)
{
cout << j <<"*"<< i << "=" << j*i <<"\t";
}
else
{
cout << endl;
break;
}
}
}
//break语句 跳出选择语句(switch)和循环结构
int a;
cout << "选择副本难度" << endl;
cout << "1 困难" << endl;
cout << "2 普通" << endl;
cout << "3 简单" << endl;
cin >> a;
switch (a)
{
case 1:
cout << "你选择的苦难难度" << endl;
break;
case 2:
cout << "你选择的普通难度" << endl;
break;
case 3:
cout << "你选择的简单难度" << endl;
break;
}
for (int i = 0; i < 10; i++)
{
if (i > 5)
{
break;
}
cout << i << endl;
}
//continue语句
//再循环语句中,跳过本次循环未执行的语句,来执行下一次循环
for (int i = 0; i <= 100; i++)
{
if (i % 2 == 0)
{
continue;
}
cout << i << endl;
}
//goto跳转语句
//如果标记的名称存在,在执行到goto语句的时候,会自动跳转到标记的位置
/*
*********
*********
goto F
*********
*********
F:*****
*/
cout << "1.xxxx" << endl;
cout << "2.xxxx" << endl;
goto FLAG;
cout << "3.xxxx" << endl;
FLAG:
cout << "4.xxxx" << endl;
cout << "5.xxxx" << endl;
system("pause");
return 0;
}