早教吧 育儿知识 作业答案 考试题库 百科 知识分享

编写函数intmymod(inta,intb)用以求a被b除之后的余数.怎么出错#includeintmymod(int,int)main(){intx,y,z;scanf("%d%d",&x,&y);z=intmymod(x,y);printf("%d",z);}intmymod(inta,intb){intc;c=a%b;returnc;}Compiling...sd.cf:\microsoft

题目详情
编写函数int mymod(int a,int b)用以求a被b除之后的余数.怎么出错
#include
int mymod(int,int)
main()
{
int x,y,z;
scanf("%d%d",&x,&y);
z=int mymod(x,y);
printf("%d",z);}
int mymod(int a,int b)
{
int c;
c=a%b;
return c;}
Compiling...
sd.c
f:\microsoft visual studio\test\sd.c(3) :error C2061:syntax error :identifier 'main'
f:\microsoft visual studio\test\sd.c(3) :error C2059:syntax error :';'
f:\microsoft visual studio\test\sd.c(3) :error C2059:syntax error :')'
执行 cl.exe 时出错.
怎么回事,
▼优质解答
答案和解析
#include int mymod(int,int);//要加双引号,这里只是声明函数void main()//最好用void{ int x,y,z; scanf("%d%d",&x,&y); z=mymod(x,y);//调用函数,用函数名即可 printf("%d",z);}int mymod(int a,int b){ int c; c=...