首页 > 代码库 > 数的四舍五入

数的四舍五入

 static void Main(string[] args)
        {
            double d;
            int i, e;
            Console.WriteLine("请输入一个整数:");
            d = double.Parse(Console .ReadLine ());
            i = (int)d;
            if (d - i > 0.5)
                e = i + 1;
            else
                e = i;
            Console.WriteLine("四舍五入后的数是:{0}",e);
            Console.Read();
            Console.ReadLine();
        }