也就写了10分钟
上代码
学废了扣1.没学废扣眼珠子
#include <iostream> using namespace std; int main(){ int N; cin>>N; int factor=1; int count=0; while(N/factor!=0){ int highNum=N/(factor*10); int curNum=(N/factor)%10; int lowNum=N-(N/factor)*factor; switch(curNum){ case 0: count+=highNum*factor; break; case 1: count+=highNum*factor+lowNum+1; break; default: count+=(highNum+1)*factor; } factor*=10; } cout<<count<<endl; return 0; }
原文:https://www.cnblogs.com/20070618hyz/p/13655933.html