楼主问用C语言编写,1楼的用C++怎么编写啊
我的C语言代码如下:
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include <math.h>
#include <conio.h>
void main()
{ int s,d=0;
int a,b,c,z,v,m;
char ch[4]={'+','-','x','/'};
srand((unsigned)time(NULL));
m=100;
b=rand()%m;
printf("%d ",b);
z=b;
for(s=0;s<3;s++)
{a=rand()%4;b=rand()%m; <br/>printf("%c %d ",ch[a],b); <br/>if (a==0) {v=z+b;z=b;}
if (a==1) {v=z-b;z=b;}
if (a==2) {v=z*b;z=b;}
if (a==3) {v=z/b;z=b;}
}
printf("= ");
loop: scanf("%d",&c);
fflush(stdin);
if (c==v) {printf("OK!");goto end;}
while (c!=v && d++!=2)
{printf("it does not matter and try it again: "); <br/>goto loop; <br/>}
printf("the result is : %d",v);
end:getch();
}
温馨提示:答案为网友推荐,仅供参考