酷代码 AI
菜单
服务商

写出首先提示用户输入名字,然后询问是否重复程序。如果回答是"yes",则执行询问对方是否执行循环的过程,然后再次循环。如果回答是"no",则输出再见的消息的c++while循环的代码

```cpp #include <iostream> #include <string> int main() { std::string name; std::string repeat; do { std::cout << "请输入你的名字:"; std::cin >> name; std::cout << "你的名字是:" << name << std::endl; std::cout << "是否重复程序? (yes/no): "; std::cin >> repeat; if (repeat == "yes") { std::string continueLoop; std::cout << "是否继续循环? (yes/no): "; std::cin >> continueLoop; if (continueLoop != "yes") { std::cout << "再见!" << std::endl; break; } } else if (repeat == "no") { std::cout << "再见!" << std::endl; break; } } while (repeat == "yes"); return 0; } ``` [2024-10-22 08:45:28 | AI写代码神器 | 530点数解答]

相关提问
实用工具查看更多
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]
数独游戏 [娱乐类]
经典推箱子 [娱乐类]
AI摸鱼五子棋 [娱乐类]