• 个人简介

    四年鸡的菜鸟来oj啦~

    语文:93 数学:98 英语:100 科学:96

    你是第Page Views Count 位来到这里的霸霸~

    该用户最近只会python 活动

    一个小游戏...

    import random
    rule = {1: '石头', 2: '剪刀', 3: '布'}
    n = input('请输入回合数:')
    n = int(n)
    r = 0
    score_p = 0
    score_c = 0
    while r < n:    
        p = input('请输入手势编号(1: 石头, 2: 剪刀, 3: 布):')
        p = int(p)
        if p not in rule.keys():
            print('编号错误,请重新输入')
            continue
        print('玩家选择:', rule[p])
        c = random.randint(1, 3)
        print('电脑选择:', rule[c])
        
        if (p == 1 and c == 2) or (p == 2 and c == 3) or (p == 3 and c == 1):
            score_p += 1
        elif p == c:
            score_p += 1
            score_c += 1
        else:
            score_c += 1
        r += 1
    print(score_c)
    print(+score_p)
    if score_p > score_c:
        print('玩家胜利')
    elif score_p < score_c:
        print('电脑胜利')
    else:
        print('平局')
    
    
  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.

题目标签

客观题
1