//统计数字问题
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"); }
相关文章推荐
- 第3周项目输出星号c
- mysql问题汇总
- 实验0:了解和熟悉操作系统
- Unity doesn't load, no Launcher, no Dash appears
- 0311 了解和熟悉操作系统实验
- 完全极大极小搜索题集
- 第3 周项目 输出星号b
- 如何在CentOS或RHEL上搭建Squid透明Web代理系统?
- [LeetCode]Permutations II
- 一个空的类都有哪些函数
- Castle 多继承选择
- django在nginx uwsgi和tornado异步方案在项目中的体验
- linux下python守护进程编写和原理理解
- 文本框高度自适应不出滚动条
- poj2594(二分图,最小路径覆盖变形)
- 流对象缓存的宏定义
- SDUSTOJ Problem G: 整数的封装(该题目要注意尽量不要使用pow函数)
- 第三周项目2 本月有几天?
- 选点问题
- PAT (Advanced Level) Practise 1049 Counting Ones (30)