View Code of Problem 107

#include<bits/stdc++.h>
using namespace std;
//三刷 
int main(){
	int m,n;
	while(cin>>m>>n){
		int cishu[10] = {0};
		for(int i=m;i<=n;i++){
			string ss = to_string(i);  //to_string(i)将数字以字符形式输出
			int len = ss.length();
			for(int j=0; j<len; j++){
				cishu[ss[j]-'0']++;
			}
		}
		
		for(int i=0; i<10; i++){
			if(i==0) printf("%d", cishu[0]);
			else printf(" %d", cishu[i]);
		}
		printf("\n");
	} 
	return 0;
} 

Double click to view unformatted code.


Back to problem 107