试题编号: 201912-1
试题名称: 报数
时间限制: 1.0s
内存限制: 512.0MB
代码:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
// 明确一点,不算上没跳的,总共是n个数
bool judice(int number){
if(number % 7 == 0){
return true;
}else{
while(number > 0){
int a = number % 10;
if(a == 7){
return true;
}
number /= 10;
}
}
return false;
}
int main(){
int number[4];
int n;
while(cin >> n){
memset(number , 0 ,sizeof(number));
int count = 0;
int jishu = 1; //报的数
while(count < n){
if(judice(jishu)){
number[jishu % 4]++; //0代表了丁
}else{
count++;
}
jishu++;
}
for(int i = 1 ; i < 4; i++){
cout << number[i] << endl;
}
cout << number[0] << endl;
}
return 0;
}