#include <stdio.h>
float calculate_expectation(float num1, float num2) { return (num1 + num2) / 2; // 计算期望值的公式:(数1 + 数2) / 2 }
int main() { float num1, num2;
printf("请输入两个数:\n");
scanf("%f %f", &num1, &num2);
float expectation = calculate_expectation(num1, num2);
printf("期望值为:%f\n", expectation);
return 0;
}
标签:return,num1,num2,float,expectation,计算,printf From: https://blog.51cto.com/u_16271069/8154230