zoukankan      html  css  js  c++  java
  • 四则运算

    def t():

        sym = ['+', '-', '×', '÷']
        f= random.randint(0, 3)
        n1 = random.randint(1, 20) 
        n2 = random.randint(1, 20)
    result = 0
    if f== 0:#加法
        result = n1 + n2
    elif f == 1:#减法,要先比较大小,防止输出负数
        n1, n2 = max(n1, n2), min(n1, n2)
        result = n1 - n2
    elif f== 2:#乘法
        result = n1 * n2
    elif f == 3:#除法,要比较大小,并循环取整除
        n1, n2 = max(n1, n2), min(n1, n2)
    while n1 % n2 != 0:
        n1 = random.randint(1, 10)
        n2 = random.randint(1, 10)
        n1, n2 = max(n1, n2), min(n1, n2)
        result = int(n1 / n2)
        print(n1, sym[f], n2, '= ', end='')
    return result
    def test():

    print('输入所需要的题目数量')
    n=int(input())
    result =[]
    m=0
    while m<=(n-1):
        print(m+1,end='、')
        result .append(t())
        print(' ')
        m=m+1
    m=0
    print('对应的答案:')
    while m<=(n-1):
        print(m+1,'、',result [m])
        m=m+1
    print('选择想要的模式')
    print('1、进行四则运算')
    print('2、制作题库')
    n=int(input())
    if n1:
    while True:
    result = t()
    j= input()
    s= int(j)
    if s result :
    print('right')
    else:
    print('error.,the answer is', result )
  • 相关阅读:
    MDL中捕获到损坏的页表页
    跟踪MmSt分页池使用情况
    了解NTFS压缩
    如何跟踪高CPU在用户模式应用程序-现场调试!
    如何与转储文件建立丰富多彩的关系
    Kernel Stack Overflows
    非分页池的消耗
    MBR反汇编
    LPC (Local procedure calls)(二)内核调试扩展
    LPC (Local procedure calls) (一)数据结构
  • 原文地址:https://www.cnblogs.com/cqszxy2020/p/14057268.html
Copyright © 2011-2022 走看看