一共有91个。实现的C++程序如下:
void testcode9()
{
int count = 0;
for (int i = 1; i <= 999; i++)
{
bool condition = ((i % 10) == 5) || (((i / 10) % 10) == 5) || (((i / 100) % 10) == 5);
if (condition && (i % 3 == 0))
{
cout << i << " ";
count++;
}
}
cout << endl;
cout << "The total num is " << count << endl;
}
最后的结果为: