一篇题解中用到的代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, x;
cin >> n >> x;
stringstream ss;
for (n++; --n; ss << n);
string s = ss.str();
cout << count(s.begin(), s.end(), x + '0') << endl;
return 0;
}
for循环的意思好像是ss可以当数组用,s[0]到s[n-1]存储了1到n的数,那s=ss是不是s[0]=ss[1],s[2]=ss[2] ....的意思?而且count函数好像是统计某个值出现的次数,而题目是要求比较数字出现的次数,比如111中1出现了三次,但是百度上说count好像不能这样识别
求助大佬 哪里理解错了呀 Orz