这是一个例子。
#include <stdio.h>
int main(void){
int score1 = 70, score2 = 58, score3 = 99;
float total = 3;
printf("Average: %f\n", (score1 + score2 + score3)/total);
}
它给了我75.666664
。而如果我像这样的代码那样将 Total 替换为 3.0
#include <stdio.h>
int main(void){
int score1 = 70, score2 = 58, score3 = 99;
printf("Average: %f\n", (score1 + score2 + score3)/3.0);
}
它给了我75.666667.