其他分享
首页 > 其他分享> > 201912-1 报数

201912-1 报数

作者:互联网

满分源码

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#pragma warning(disable:4996)
using namespace std;

const int N = 10000;
int main()
{
	int n;
	scanf("%d", &n);
	int sum = 0;//总共报出的数字
	int person[4] = { 0 };
	for (int i = 1; i <= N; i++) {
		//7的倍数:i % 7 != 0

		//尾数为7:i/1%10 !=7

		//倒2为7:71,171,
		//171:i/10%10 !=7

		//倒3为7:701,1701
		//701:i/100%10 !=7

		//倒4为7:7001,17001
		//7001:i/1000%10 !=7

		if ((i % 7 != 0)&&(i / 1 % 10 != 7)&&(i / 10 % 10 != 7)&&(i / 100 % 10 != 7)&&(i / 1000 % 10 != 7)) {
			sum++;
		}
		else {
			if (i % 4 == 1)person[0]++;
			if (i % 4 == 2)person[1]++;
			if (i % 4 == 3)person[2]++;
			if (i % 4 == 0)person[3]++;
		}
		if (sum == n)break;
	}
	printf("%d\n%d\n%d\n%d\n", person[0], person[1], person[2], person[3]);


	return 0;
}

标签:10,person,int,sum,++,&&,201912,报数
来源: https://blog.csdn.net/weixin_45784564/article/details/120378018