//方法1:直接利用库函数round(); //方法2:加0.5 int main() { float num; scanf("%f",&num); num = round(num); printf("%d\n",(int)num); //printf("%d\n",(int)(num + 0.5)); return 0; }