数的四舍五入

 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();
        }

posted @ 2014-07-08 20:39  Shaine  阅读(114)  评论(0编辑  收藏  举报