用C语言写一个电子秤成分占比代码

首先,您需要先定义和初始化两个变量,一个代表总重量,另一个代表成分重量:float totalWeight;float componentWeight; 然后,请输入总重量和成分重量:scanf("%f", &totalWeight);scanf("%f", &componentWeight); 最后,计算成分占比并输出:float ratio = componentWeight / totalWeight; printf("成分占比:%f\n", ratio);

猜你喜欢

转载自blog.csdn.net/weixin_42601134/article/details/129489442