运用c语言编写一游戏。游戏面向小学1~2年级学生,随机选择两个整数和加减法形成算式要求学生解答。先谢啦
1个回答

#include

#include

#include

#include

void main()

{

int num=0,add=0; /* 答题数,得分 */

int score[3]={10,7,5};

char str[20],str1[10][20];

while(1)

{

int a=0,b=0,d=0,c=0,k=0,i=0,j=-1,result;

char sf[2]={'+','-'};

/* 出题 */

while(1)

{

a=rand()%51;

b=rand()%51;

d=rand()%2;

if(d==0)c=a+b;

else c=a-b;

if(c>=0 && c