CSP201912-1报数

CSP201912-1报数_第1张图片
CSP201912-1报数_第2张图片
源代码

#include 
#include 
using namespace std;
int Judge(int counter) {
	char buff[10];
	_itoa(counter, buff, 10);//将整数转成字符串
	string str = buff;
	return str.find('7');
}
int main()
{
	int n;
	int counter = 0;
	int player[4] = { 0 };
	cin >> n;
	while (n > 0) {
		counter++;
		if (counter % 7 == 0 || Judge(counter) != -1) {
			player[(counter - 1) % 4]++; 
		}
		else {
		n--;
		}
	}
	for (int i = 0; i < 4; i++) {
		cout << player[i] << endl;
	}
}

你可能感兴趣的:(CSP)