如PI=3.1415……,在提供半径 r 后,周长 double C = 2*PI*r,此时,我想精确到 C 小数点后的两位,这里请教了!

解决方案 »

  1.   

    C = (int)(C * 100)/100.0F;
      

  2.   

    楼主看看!
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Xml;
    using System.Collections;namespace ConsoleApplication1
    {
        class Program
        {        public Program()
            {
                const double PI=3.1415;
                //假设半径为3
                double c = 2 * PI * 3;
                Console.WriteLine(Math.Round(c, 2));
            }        static void Main(string[] args)
            {
                Program p1 = new Program();
                Console.ReadLine();
            }
        }
    }
      

  3.   

    double C = 2*PI*r,
    C=Convert.ToDouble(C.ToString("F2"));