您的位置:首页 > 其它

//统计数字问题

2016-03-11 19:15 330 查看
//统计数字问题
/*
统计全部页码分别用了多少0~9
*/
#include<iostream>
using namespace std;

int a[9]={0};//初始化为0
void Solution()
{
int n;
cin>>n;
for(int i=0;i<=n;i++)
{
int x=i;
if(x==0)//判断是否为0
a[0]++;
else
{
while(x/10)//判断是否多位数
{
a[x%10]++;
x=x/10;
}
a[x]++;
}

}
for(int i=0;i<10;i++)
cout<<a[i]<<endl;

}
int main()
{
Solution();
system("pause");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: