UVa1225——Digit Counting

来源:互联网 发布:淘宝上阿迪的正品店铺 编辑:程序博客网 时间:2024/05/17 02:14

水题。暴力过。

AC的代码:

#include <iostream>#include <cstring>using namespace std;int main(){int n, t;int ans[10];while(cin >> t){while(t--){cin >> n;memset(ans, 0, sizeof(ans));for(int i = 1; i <= n; i++){int x = i;while(x){ans[x % 10]++;x /= 10;}}for(int j = 0; j < 10; j++)j != 9 ? cout << ans[j] << ' ' : cout << ans[j] << endl;}}return 0;}


0 0
原创粉丝点击