方法一:
#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<queue>
using namespace std;
int main() {
int n; //报出n个数后结束游戏
cin >> n;
int calln = 1; //报出的数字
vector<int> person(4); //代指甲乙丙丁
int turn = 0; //0,1,2,3分别为甲乙丙丁
bool if7; //判断数字中是否含有7
for (int i = 0; i < n; i++)
{
if7 = false;
int tempn = calln;
while (tempn > 0)
{
int x = tempn % 10;
if (x == 7)
{
if7 = true;
break;
}
tempn /= 10;
}
if (calln % 7 == 0 || if7)
{
person[turn]++;
turn = (turn + 1) % 4;
calln++;
i--;
continue;
}
turn = (turn + 1) % 4;
calln++;
}
for (int i = 0; i < 4; i++)
{
cout << person[i] << endl;
}
return 0;
}
判断数字中是否有7也想不到有什么更好的办法。