float a=1/2;

会输出a=0
正确写法

float a=(float)1/2;

或者直接初始化,避免赋值操作

float a(1/2);
posted on 2022-05-02 20:11  FrostyForest  阅读(68)  评论(0)    收藏  举报