main()函数中已经定义time是int变量了, 所以time就不认为是函数了,而srand(time(NULL))又把time当作函数使用, 因此它说你调用的不是函数.
解决办法:
除srand(time(NULL))一行外,其他所有的time都改成tim即可.
如果运行还有问题就是别处的原因了.
/*通过上机测试*/
#include
#include
#include
#include
main()
{
int num1,num2,result,time1=0;/*不要定义和标准函数一样变量*/
char ch;
/*时间型要这样*/
time_t t;
while(1)
{
gotoxy(30,12);
srand((unsigned) time(&t));/*srand函数的用法*/
num1=10+rand()%90;num2=10+rand()%90;
while(time1<3)
{
textcolor(GREEN);
cprintf("%d+%d=",num1,num2); scanf("%d",&result);
textcolor(RED);
/*多加两个getch()要不然看不到提示you are right!和you are wrong!*/
if(num1+num2==result) {
cprintf("you are right!");
scanf("%c",&ch);getch();
clrscr();break;}
if(num1+num2!=result){
cprintf("you are wrong!");
scanf("%c",&ch);getch();
clrscr();
time1++;gotoxy (30,12);}
}
printf("do you want to continue?\n");
scanf("%c",&ch);
if(ch=='q')
{
break;
}
}
}