书页数码问题
#include
using namespace std;
#define MAX 50
int a[MAX] = { 0 };
int n;
void bfs(int s)
{
if (s > n)
{
for (int i = 1; i < 10; i++)
cout << i << " 出现: " << a[i] << endl;
return;
}
int tempt = s;
while (tempt> 0)
{
a[tempt% 10]++;
tempt = tempt / 10;
}
bfs(s + 1);
}
int main()
{
cin >> n;
bfs(1);
return 0;
}
如有不完善之处,请多多指教