用c语言给小学生出加法考试题 编写一个程序,给学生出一道加法运算题,然后判断学生输入的答案对错与否,

1个回答

  • #include "time.h"

    #include "stdio.h"

    #include "stdlib.h"

    int main()

    {

    int a,b,c,d;

    srand(time(0)) ;

    while(1)

    {

    a = rand()%100; b=rand()%100; printf("%d+%d=", a,b);

    scanf("%d", &d);

    if(d < 0) return 0;

    if(d==a+b)printf("Right!");

    else printf("Error!");

    }

    return 0;

    }