奖券数目(C++)

                               奖券数目

有些人很迷信数字,比如带“4”的数字,认为和“死”谐音,就觉得不吉利。
虽然这些说法纯属无稽之谈,但有时还要迎合大众的需求。某抽奖活动的奖券号码是5位数(10000-99999),要求其中不要出现带“4”的号码,主办单位请你计算一下,如果任何两张奖券不重号,最多可发出奖券多少张。

样例输入:

样例输出:
52488

#include<iostream>
using namespace std;
bool judge(int n){
    
    
	while(n){
    
    
		if(n%10==4){
    
    
			return true;
		}
		n = n/10;
	}
	return false;
}
int main()
{
    
    
	int count = 0;
	for(int i=10000;i<100000;i++){
    
    
		if(!judge(i)){
    
    
			count++;
		}
	}
	cout<<count<<endl;
	return 0;	
} 

猜你喜欢

转载自blog.csdn.net/weixin_51430516/article/details/115338288