编写函数,其功能是对传送过来的两个浮点数求出和值与差值,并通过形参传回调用函数。
注意:此题用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);
//}

沐小轲
9 声望0 粉丝

C++初学者


引用和评论

0 条评论