#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> void main() { double moeny = 0; scanf("%lf",&moeny); printf("多少%f元", moeny); double rufest = (int)(moeny * 10 + 0.5) / 10.0; printf(" rufest=%f", rufest); if (moeny<rufest) { printf("%f元四舍五入",moeny-rufest); } system("pause"); }
还是微软牛逼:C#两句话搞定四舍六入:五取偶
double i = Math.Round(1.25, 1); Console.WriteLine(i);