UVa1225 DIgit Counting
来源:互联网 发布:java string split 点 编辑:程序博客网 时间:2024/05/22 02:03
Problem Description
把前n(n<=10000)个整数顺次写在一起:例如12: 123456789101112 数一数0-9各出现多少次
Sample Input
2
3
13
Sample Output
0 1 1 1 0 0 0 0 0 0
1 6 2 2 1 1 1 1 1 1
代码:
#include<stdio.h>#include<string.h>char a[10005][100005];char s[1000000];int main(){ int t, i, n, b[15]; scanf("%d", &t); while(t--) { memset(a, 0, sizeof(a)); memset(s, 0, sizeof(s)); memset(b, 0, sizeof(b)); scanf("%d", &n); for(i = 1; i <= n; i++) { sprintf(a[i - 1], "%d", i);//打印到字符串 } for(i = 0; i < n; i++) { strcat(s, a[i]);//连接成一个串 } for(i = 0; s[i]; i++) { b[s[i] - '0']++;//记录数据 } for(i = 0; i < 9; i++) { printf("%d ", b[i]); } printf("%d\n", b[i]); } return 0;}
0 0
- UVA1225 Digit Counting
- UVA1225 Digit Counting
- uva1225 - Digit Counting
- Digit Counting uva1225
- UVa1225 Digit Counting
- UVa1225 Digit Counting
- UVA1225 UVALive3996 Digit Counting
- UVa1225 Digit Counting
- UVa1225 Digit Counting
- UVa1225 Digit Counting
- UVA1225 Digit Counting
- UVa1225 Digit Counting
- UVa1225 - Digit Counting
- UVa1225 DIgit Counting
- UVa1225-Digit Counting
- 3.3 Digit Counting UVA1225
- UVa1225——Digit Counting
- UVa1225 Digit Counting 数数字
- linux下lz4解压缩的安装包
- gbk to utf-8以及java默认编码之间的转化
- 元素设为inline-block元素里有内容与无内容导致的错位问题
- 生命周期Activity ,Fragment,Service
- 重写equal 的同时为什么必须重写hashcode?
- UVa1225 DIgit Counting
- 获取CPU性能信息代码
- PetaPoco 快速上手
- 挑战 P234 poj3281
- 目标检测--Accurate Single Stage Detector Using Recurrent Rolling Convolution
- 数组和链表的区别
- 盒子弧度
- Android——EventBus3.0的使用详解
- js加减乘除丢失精度问题解决方法