# include <stdio.h> void mian() { int a = 0, b = 0, sum = 0; add(); printf("%d\n",sum);
} void add() { int x = 0, y = 0, z = 0; z = x + y; return 0; }
你试试看,应该对
加载中...
2楼-- · 2022-11-01 12:33
#include <stdio.h> #define type int type add(type a, type b) { type ret; ret=a+b; return ret; } int main() { type a,b; scanf("%d%d", &a,&b); printf("%d\n", add(a,b)); return 0; }
# include <stdio.h>
void mian()
{
int a = 0, b = 0, sum = 0;
add();
printf("%d\n",sum);
}
void add()
{
int x = 0, y = 0, z = 0;
z = x + y;
return 0;
}
你试试看,应该对
#include<stdio.h>
float Add(float x,float y)//函数定义
{float s;
s=x+y;
return(s);
}
int main()
{
float x,y,sum;
char c;
while(c!='\\')//继续输入下一组数据,直到输入\键结束循环
{
printf("please input two number:\n");
scanf("%f%f",&x,&y);
printf("the result is:");
sum=Add(x,y);//调用函数,因为add函数在main函数之前定义了,所以main函数中无需再声明,而直接调用add
printf("%f\n\n",sum);
c=getchar();//
}
printf("The end\n");
getchar();//按回车键退出
}本回答被提问者采纳
一周热门 更多>