小编Anc*_*bis的帖子

c ++ While循环终止功能

因为它在早些时候工作得很好,但是当我去添加一些其他功能时,我的程序吓坏了,我无法将它恢复到原来的状态.

我让我写一个摇滚/纸/剪刀程序来对抗计算机,任何有关循环不断终止的帮助都会很精彩

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;


void RPSout(char);
int RPScomp();

int main() {

    char choice;
    int endit=0;

    while (endit == 0)
    {
        cout << "\n\n\tReady to play Rock/Paper/Scissors against the computer??(please choose R/P/S)(Q to quit)\n";
        cin >> choice;

        RPSout(choice);

        if (choice=='Q'||'q')
            {endit=1;}
    }
    return 0;
}


void RPSout(char choose)
{
    int RPS =0;
    int comp=0;
    switch (choose)
    {
    case 'R':
    case 'r':
    {
        cout <<"Your choice: Rock";
        break;
    }
    case 'P':
    case 'p':
    {
        cout …
Run Code Online (Sandbox Code Playgroud)

c++ loops while-loop srand switch-statement

4
推荐指数
1
解决办法
79
查看次数

标签 统计

c++ ×1

loops ×1

srand ×1

switch-statement ×1

while-loop ×1