B4411题解
这道题可以用“打表”!!! 啥也不说了,这题简单 参考代码:
int beautiful[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9,
11, 22, 33, 44, 55, 66, 77, 88, 99,
111, 222, 333, 444, 555, 666, 777, 888, 999,
1111
};
int total = 28; // 总个数
int count = 0;
for (int i = 0; i < total; i++) {
if (beautiful[i] <= n) {
count++;
} else {
break;
}
}
cout << count << endl;
return 0;
} 懂了吗? 制作不易,点个赞吧