zoukankan      html  css  js  c++  java
  • 小学二年级四则运算

    #include <stdlib.h>
    #include <stdio.h>
    #include <time.h>
    void main()
    {
    int i,k,l,x,n,m,p;
    char y;
    srand((unsigned)time(NULL));
    for (i = 0; i<30;i++)
    {
    k = rand() % 100;

    l = rand() % 100;

    x = rand() % 4;


    switch (x) {
    case 0:y = '+';break;
    case 1:y = '-';
    if (k < l) {
    p = k; k = l;l = p;
    }
    break;
    case 2:y = '*';break;
    case 3:y = '/';
    if (l == 0)l++;
    if (l > 10) { l = l % 10; }
    break;
    }

    printf("%d%c%d= ", k, y, l);

    }
    for (i = 0; i<30;i++)
    scanf_s("%d", &n);
    for (i = 1; i<=30;i++)
    {
    k = rand() % 100;

    l = rand() % 100;

    x = rand() % 4;


    switch (x) {
    case 0:y = '+';m = k + l;break;
    case 1:y = '-';if (k < l) {
    p = k; k = l;l = p;
    }
    m = k -l;break;
    case 2:y = '*';m = k * l;break;
    case 3:y = '/';if (l == 0)l++;
    if (l > 10) l = l % 10;
    m = k / l;break;
    }

    printf("第%d题正确答案为%d", i, m);

    }

    }


  • 相关阅读:
    SpringBoot整合阿里云OSS
    UVALive
    HDU 5794 A Simple Chess dp+Lucas
    数论
    UVALive
    UVALive
    HDU 5792 World is Exploding 树状数组+枚举
    UVALive
    UVALive
    UVALive
  • 原文地址:https://www.cnblogs.com/sunbuqiao/p/5268998.html
Copyright © 2011-2022 走看看