C++的猜拳游戏,窒息,啥也不会,求解答

img

img

img

img

#include <iostream> 
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
    char gamer;  // 玩家出拳
    int computer;  // 电脑出拳
    int result;  // 比赛结果
    // 为了避免玩一次游戏就退出程序,可以将代码不断循环
    while (1){
            cout<<"\n 这是一个猜拳的小游戏,请输入你要出的拳头:\n";
        cout<<"A :  剪刀\nB :  石头\nC :  布\nD :  不玩了\n";
        scanf("%c%*c",&gamer);
        switch (gamer){
            case 65:  //A
            case 97:  //a
                gamer=4;
                break;
            case 66:  //B
            case 98:  //b
                gamer=7;
                break;
            case 67:  //C
            case 99:  //c
                gamer=10;
                break;
            case 68:  //D
            case 100:  //d
                return 0;
          
            default:
                cout<<"   你的选择为"<<gamer<<"选择错误,退出...\n";
                getchar();
                system("cls"); //清屏
                return 0;
                break;
        }
      
        srand((unsigned)time(NULL));  //把当前的时间作为随机数种子
        computer=rand()%3;  //产生随机数并取余,得到电脑出拳
        result=(int)gamer+computer;  //gamer 为 char 类型,数学运算时要强制转换类型
 
        cout<<"电脑出了";
        switch (computer)
        {
            case 0:cout<<"剪刀\n";break; //4    1
            case 1:cout<<"石头\n";break; //7  2
            case 2:cout<<"布\n";break;   //10 3
        }
 
        cout<<"你出了";
        switch (gamer)
        {
            case 4:cout<<"剪刀\n";break;
            case 7:cout<<"石头\n";break;
            case 10:cout<<"布\n";break;
        }
        if (result==6||result==7||result==11) 
            cout<<"你赢了!";
        else if (result==5||result==9||result==10) 
            cout<<"电脑赢了!";
        else 
            cout<<"平手!";
        system("pause>nul&&cls");  // 暂停并清屏
    }
    return 0;
}