酷代码 AI
菜单
服务商

C++编程:揭秘1 - 1000内所有水仙花数!

以下是使用 C++编写的程序来找出所有的水仙花数: ```cpp #include <iostream> using namespace std; int main() { for (int num = 100; num <= 999; num++) { int hundreds = num / 100; int tens = (num % 100) / 10; int units = num % 10; if (num == (hundreds * hundreds * hundreds + tens * tens * tens + units * units * units)) { cout << num << " "; } } return 0; } ``` ######[AI写代码神器 | 147点数解答 | 2024-10-15 21:53:45]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]