1.敲桌子程序 找出1-100中的数字,7的倍数,个位数字为7,十位数字为7
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main() { int num; for (num = 1; num <= 100; num++) { if (num % 7 == 0 || num % 10 == 7 || num / 10 == 7) { cout << "敲桌子" << endl; } else { cout << num << endl; } } return 0; }
2.打印星图程序 利用嵌套循环打印一张星图
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main() { int i, j; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { cout << "* "; } cout << endl; } return 0; }