结果易懂,但凡和7有关,都输出相应的关系。关系分为三种,7的倍数,十位是7,个位是7
#include<iostream>
using namespace std;
int main()
{
for (int num = 1; num <= 100; num++)
{
if (num % 7 == 0)//是7的倍数
{
cout << "7的倍数" ;
if (num / 10 == 7)//并且70-79
{
cout << "、是70+";
if (num % 10 == 7)//并且个位上有7
cout << "、个位是7";
}
cout << endl;
}
else if (num / 10 == 7)//70-79
cout << "70+" << endl;
else if (num % 10 == 7)//个位上有7
cout << "个位是7" <<endl;
else
cout << num << endl;
}
system("pause");
return 0;
}
运行结果: