游戏《敲桌子》
初步学习for循环语句
游戏内容:从1开始数到数字100,如果数字各位含有7,或数字十位含有7,或者数字是7的倍数时,打印敲桌子三个字;其余数字直接打印出数字。
#include<bits/stdc++.h>
using namespace std;
int main() {
//敲桌子游戏 for循环
for (int i = 1; i <= 100; i++) {//从1到100
if (i % 7 == 0 || i / 10 == 7 || i % 10 == 7) {//判断条件
cout << "敲桌子" << endl;
}
else {
cout << i<<endl;
}
}
system("pause");
return 0;
}
学习过程:很简单的一个东西,属于0基础的,只用到了一个for循环