编写函数,其性能是对传送过去的两个浮点数求出和值与差值,并通过形参传回调用函数。
留神:此题用C语言实现时,必须应用指针办法解决,只提交头文件和
void compute(float a,float b,float c,float d)
函数,零碎将主动附加上面的main函数后运行,请复制上面的main函数用于调试函数。
其余语言的答案无此要求。
intmain(){
float a,b,c,d;
scanf("%f%f",&a,&b);
compute(a,b,&c,&d);
printf("%g %g",c,d);
}
输出
两个浮点数a,b
输入
a+b a-b 用%g输入
样例输出 Copy
1.5 2.5
样例输入 Copy
4 -1
代码示例(本人写的,只能过平台,不完满)
//#include<iostream>//using namespace std;//void compute(float a,float b,float *c,float *d);////int main(){// float a,b,c,d;// scanf("%f %f",&a,&b);// compute(a,b,&c,&d);// printf("%g %g",c,d);//}//void compute(float a,float b,float *c,float *d){// *c = (a + b);// *d = (a - b);//}