C语言疑问: 出现warning C4013: 'add' undefined; assuming extern returning int 怎么解决啊 ~ 谢谢啦
#include<stdio.h>#include<stdlib.h>#include<time.h>intcount=0,ok=0,a,b;voidmain(){int...
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int count=0,ok=0,a,b;
void main()
{
int x,y,op,end=0;
srand(time(NULL));
printf("\n***** 这是一个加减法运算的小游戏,回答为 999 表示程序结束 *****\n");
while(end!=999)
{
op=rand()%2;
x=1+rand()%99;
y=1+rand()%99;
a=add(x,y);b=minus(x,y);
end=(op==0)?a:b;
}
printf("\n");
}
int add(int x,int y)
{
int answer; long accuracy;
printf("\n %d+%d=",x,y);
scanf("%d",&answer);
while(answer!=999){
if(answer==(x+y)){ count++;ok++;accuracy=(ok/count)*100;
printf(" 回答正确!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);return 1;}
else {count++;accuracy=(ok/count)*100;
printf(" 回答错误!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);
return 1;}
}
return 999;}
int minus(int x,int y)
{
int answer; long accuracy;
printf("\n %d-%d=",x,y);
scanf("%d",&answer);
while(answer!=999){
if(answer=(x-y)){ count++;ok++;accuracy=(ok/count)*100;
printf(" 回答正确!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);return 1;}
else {count++;accuracy=(ok/count)*100;
printf(" 回答错误!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);
return 1;}
} 展开
#include<stdlib.h>
#include<time.h>
int count=0,ok=0,a,b;
void main()
{
int x,y,op,end=0;
srand(time(NULL));
printf("\n***** 这是一个加减法运算的小游戏,回答为 999 表示程序结束 *****\n");
while(end!=999)
{
op=rand()%2;
x=1+rand()%99;
y=1+rand()%99;
a=add(x,y);b=minus(x,y);
end=(op==0)?a:b;
}
printf("\n");
}
int add(int x,int y)
{
int answer; long accuracy;
printf("\n %d+%d=",x,y);
scanf("%d",&answer);
while(answer!=999){
if(answer==(x+y)){ count++;ok++;accuracy=(ok/count)*100;
printf(" 回答正确!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);return 1;}
else {count++;accuracy=(ok/count)*100;
printf(" 回答错误!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);
return 1;}
}
return 999;}
int minus(int x,int y)
{
int answer; long accuracy;
printf("\n %d-%d=",x,y);
scanf("%d",&answer);
while(answer!=999){
if(answer=(x-y)){ count++;ok++;accuracy=(ok/count)*100;
printf(" 回答正确!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);return 1;}
else {count++;accuracy=(ok/count)*100;
printf(" 回答错误!\n您总共回答了%d道题,答对%d道题,答对率为%.2f%。\n",count,ok,accuracy);
return 1;}
} 展开
展开全部
你得在main前面声明函数或者把你的函数写在main的前面
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int count=0,ok=0,a,b;
int add(int x,int y);
int minus(int x,int y);
void main()
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int count=0,ok=0,a,b;
int add(int x,int y);
int minus(int x,int y);
void main()
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询