CCF201912-1(C++)

题目:在这里插入图片描述

代码:

#include<iostream>
using namespace std;
int findnum(int num){
 while(num){
  int x = num%10;
  num = num/10;
  if(x==7){
   return 1;
  }
 }
 return 0;
}
int main(){
 int n;
 cin >> n;
 int cot1 = 0;
 int cot2 = 1;
 int ans[4] = {0};
 for(;;){
  for(int i = 0;i<4;i++){
   if(cot2%7==0 || findnum(cot2)){
    ans[i] ++;
   }
   else{
    cot1++;
   }
   cot2 ++;
   if(cot1==n){
    for(int i = 0;i<4;i++){
     cout << ans[i] << endl;
    }
    return 0;
   }
  }
 }
}
发布了45 篇原创文章 · 获赞 0 · 访问量 1004

猜你喜欢

转载自blog.csdn.net/jokerxsy/article/details/104145261
今日推荐