chaper3_exerise_Uva1225_digit_counting

Posted 豆子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了chaper3_exerise_Uva1225_digit_counting相关的知识,希望对你有一定的参考价值。

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<cstring>
 4 using namespace std;
 5 const int maxn = 10010;
 6 
 7 int main(void)
 8 {
 9     int N, n;                  //N组数据 , n前n个整数顺次
10     cin >> N;
11     for (int i = 0; i < N; i++)
12     {
13         char buf[maxn];
14         int count[10] = {0};
15         cin >> n;
16         for (int i = 1; i <= n; i++)
17         {
18             sprintf(buf,"%d",i);    
19             for (int j = 0; j < strlen(buf); j++)
20             {
21                 count[buf[j]-0]++;
22             }
23         }    
24         for (int k = 0; k < 9; k++)
25             cout << count[k] <<  ;     //注:UVa里不允许多输出空格
26         cout << count[9] << endl;
27     }
28     return 0;
29 } 

 

以上是关于chaper3_exerise_Uva1225_digit_counting的主要内容,如果未能解决你的问题,请参考以下文章

chaper3_exerise_UVa455_周期串

chaper3_exerise_Uva1568_Molar_Mass_分子量

[CodeForces - 1225D]Power Products 数论 分解质因数

CF1225G To Make 1

UVA 1225 Digit Counting

算法竞赛入门经典(第二版)3-3数数字UVA1225