【发布时间】:2020-12-19 15:38:01
【问题描述】:
所以我有这个用于电阻转换的代码,我需要在 1 个函数内进行所有计算,但我不确定如何执行此操作,所以这里是公式的屏幕截图。Formulas for calculations。有没有人知道如何做到这一点,任何帮助都会很棒。 我注释掉的可以忽略,因为与函数计算无关。
float conversions (float R1, float R2, float R3)
{
//Star to Delta conversion
//RA calculation
return ((R1*R2+R2*R3+R3*R1)/R3);
}
int main(void){
float R1,R2,R3;
//printf("Please enter an S to convert Star to Delta, a D to convert Delta to Star, and Q to quit ");
//char x = UserInput();
// printf ("You selected %c\n", x);
printf("Please enter a value for R1 R2 and R3 seperated by a space: ");
scanf("%f %f %f", &R1, &R2, &R3);
printf("\n %f", conversions (R1, R2, R3)); // test to ensure values were being passed to variables
【问题讨论】:
-
在你的 c 课程中,你有没有接触过指针、数组或结构体?
-
添加一个浮点类型的函数来计算这个:R1 = Ra*Rb/Ra+Rb+Rc 并且你改变参数的顺序 (Ra,Rb,Rc) 来计算其他的,也计算 ((R2*R1+R2*R3+R3*R1)/R3)
-
你的意思是创建一个与我已有的函数分开的新函数,因为它要求所有计算都在同一个函数中完成
标签: c function calculation