UVa1225 Digit Counting】的更多相关文章

Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N (1 < N < 10000) . After that, he counts the number of times each digit (0 to 9) appears in the sequen…
#include <stdio.h>#include <string.h> int main(){    int T, N, i, j;    int a[10];    scanf("%d", &T);    while (T--)    {        memset(a, 0, sizeof(a));        scanf("%d", &N);        for (i = 1; i <= N; ++i)  …
UVa 1225 题目大意:把前n(n<=10000)个整数顺次写在一起,12345678910111213...,数一数0-9各出现多少字 解题思路:用一个cnt数组记录0-9这10个数字出现的次数,先将cnt初始化为0,接着让i从1枚举到n, 对每个i,处理以活的i的每一个位置上的数,并在相应的cnt下标上+1 最后输出cnt数组即可 /* UVa 1225 Digit Counting --- 水题 */ #include <cstdio> #include <cstring…
题目连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=247&page=show_problem&problem=3666 13764622 1225 Digit Counting Accepted C++11 0.035 2014-06-18 07:44:02 1225 - Digit Counting Time limit: 3.000 seconds Tru…
#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ char s[10000]; int a0 = 0, a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0, a9 = 0; scanf("%s", s); for (int i = 0; i < strlen(s); i++) { if (s[…
题目描述:算法竞赛入门经典习题3-3 #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { ] ; memset(num,,) ; ]; scanf("%s",s) ; int n = strlen(s) ; ;i<n;i++) ;j<;j++){ '==j) num[j]++ ; } ;i<;i++){ printf("%d:%d\n&qu…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 水模拟 [代码] #include <bits/stdc++.h> using namespace std; int a[10]; int main() { /*freopen("F:\\rush.txt", "r", stdin);*/ int T; scanf("%d", &T); while (T--) { int n; scanf("%d&q…
#include<stdio.h> #include<string.h> int main() { char s[100]; scanf("%s",s); int len = strlen(s); int a[10]; memset(a ,0 ,sizeof(a)); int i; for(i = 0;i < len;i++){ a[(s[i] - '0')] += 1; } for(i = 0;i < 10;i++){ printf("%…
​ Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N (1 < N < 10000). After that, he counts the number of times each digit (0 to 9) appears in the seque…
思路: 利用java 特性,将数字从1 一直加到n,全部放到String中,然后依次对strring扫描每一位,使其carr[str.charAt(i)-'0']++; 最后输出carr[i],即可. 13 string=12345678910111213 carr[1]++.carr[2]++.carr[3]++....carr[1]++.carr[1]++.carr[1]++.carr[2]++.carr[1]++.carr[3]++ AC Code: import java.util.Sc…