主页
C++
C++ While 循环示例
demo_while_loop_reallife4
运行 ❯
×
更改方向
保存代码
更改主题
#include
using namespace std; int main() { int dice = 1; while (dice <= 6) { if (dice < 6) { cout << "No Yatzy\n"; } else { cout << "Yatzy!\n"; } dice = dice + 1; } return 0; }
No Yatzy
No Yatzy
No Yatzy
No Yatzy
No Yatzy
Yatzy!