201912-1 报数

201912-1 报数

代码:

#include <iostream>
#include <vector>


using namespace std;


bool jump(int num){
    if(num%7 == 0){
        return true;
    }
    while(num != 0){
        int temp = num;
        num = (int)num/10;
        int currnum = temp - num*10;
        if(currnum == 7){
            return true;
        }
    }
    return false;
}

int main()
{

    int n;
    while(scanf("%d",&n) != EOF){
        vector<int> count(4,0);
        int curr = 0;
        for(int i = 1; curr < n;i++){
            int p = (i-1)%4;
            if(jump(i)){
                count[p]++;
            }else{
                curr++;
            }
        }

        for(int i = 0; i < 4;i++){
            printf("%d\n",count[i]);
        }
    }

    return 0;
}

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页