四则运算三十道题

 

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int main() { 

    int i;

    int num1, num2;

    int  op,result, score=0;

    char oper[]={'+','-','*','/'};

    srand(time(0));



    for(i=0; i<30; i++)

    {

        printf("第%d题 ", i+1);

        num1 = rand()%101;

        num2 = rand()%101;

        op = rand()%4;

        switch(op){

            case 0:

            printf("%d %c %d = \n", num1, oper[op], num2);

              break;

            case 1:

             printf("%d %c %d = \n", num1, oper[op], num2);

               break;

            case 2:

              printf("%d %c %d = \n", num1, oper[op], num2);

                break;

            case 3:

              printf("%d %c %d = \n", num1, oper[op], num2);

              break;

        }

    }    

    return 0;

    }

 

posted @ 2018-10-01 19:37  丶koenigsegg  阅读(331)  评论(0编辑  收藏  举报