标签:oat 测试程序 简单 pre std class 计算 2.0 span
本题要求实现一个计算输入的两数的和与差的简单函数。
void sum_diff( float op1, float op2, float *psum, float *pdiff );
其中op1
和op2
是输入的两个实数,*psum
和*pdiff
是计算得出的和与差。
#include <stdio.h>
void sum_diff( float op1, float op2, float *psum, float *pdiff );
int main()
{
float a, b, sum, diff;
scanf("%f %f", &a, &b);
sum_diff(a, b, &sum, &diff);
printf("The sum is %.2f\nThe diff is %.2f\n", sum, diff);
return 0;
}
/* 你的代码将被嵌在这里 */
4 6
The sum is 10.00
The diff is -2.00
#include <stdio.h> void sum_diff( float op1, float op2, float *psum, float *pdiff ); int main() { float a, b, sum, diff; scanf("%f %f", &a, &b); sum_diff(a, b, &sum, &diff); printf("The sum is %.2f\nThe diff is %.2f\n", sum, diff); return 0; } /* 你的代码将被嵌在这里 */ void sum_diff( float op1, float op2, float *psum, float *pdiff ) { *psum=op1+op2; *pdiff=op1-op2; }
标签:oat 测试程序 简单 pre std class 计算 2.0 span
原文地址:https://www.cnblogs.com/2228212230qq/p/9265137.html