C++之从来没有一次一次性过过
查看原帖
C++之从来没有一次一次性过过
811469
None_g楼主2024/5/16 17:38

我就是你永远能在讨论区看见的人

#include <bits/stdc++.h>
using namespace std;
int js[10],n,m,j,h,f,s;
int gh(int a) {
	j=1;
	for (s=1; s<=a; s++) {
		j=j*10;
	}
	return j;//有事没事写函数,防止忘完 
}
int main() {
	memset(js,0,sizeof(js));
	cin>>n>>m;
	s=1;
	while (m/gh(s)>0) {
		for (j=n; j<=m; j++) {
			if (j==0) continue;
			if(j%10==1) js[1]++;
			if(j%10==2) js[2]++;
			if(j%10==3) js[3]++;
			if(j%10==4) js[4]++;
			if(j%10==5) js[5]++;
			if(j%10==6) js[6]++;
			if(j%10==7) js[7]++;
			if(j%10==8) js[8]++;
			if(j%10==9) js[9]++;
			if(j%10==0) js[0]++;
		}
		s++;
	}//开始从每一位判断 
	j=1;
	while (j>=10){ 
	cout<<js[j]<<" ";
	j++;
	} //输出 
}
2024/5/16 17:38
加载中...