返回题解分享
讨论 / 题解分享/ 帖子详情

特别数的和(编程题) - 题解

#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdio>
#include<climits>
using namespace std;
bool check(int x){
	while(x){
		int temp=x%10;
		x/=10;
		if(temp==2 ||temp==0 || temp==1 ||temp==9) return true;
	}
	return false;
}
int main(){
	int n;
	cin>>n;
	int res=0;
	for(int i=1;i<=n;i++){
		if(check(i)) res+=i;	
	}
	cout<<res;

}
0 回复 0 转发 0 喜欢 0 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!