2023-07-26 14:20发布
#include<stdio.h>#definetypeinttypeadd(typea,typeb){typeret;ret=a+b;returnret;}intmain(){typea,b;scanf("%d%d",&a,&b);printf("%d\n",add(a,b));return0;}
#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函数中无需再声明,而直接调用addprintf("%f\n\n",sum);c=getchar();//}printf("The end\n");getchar();//按回车键退出}本回答被提问者采纳
# 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;}你试试看,应该对
最多设置5个标签!
#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();//按回车键退出
}本回答被提问者采纳
# 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;
}
你试试看,应该对
一周热门 更多>