int main(){double a;scanf("%lf", &a);//%f是单精浮点 %lf双精浮点printf("%d",(int)(a+0.5));system("pause");return 0;}你那个else k=k是错的 k不变就好 不要给自己赋值