示例#1
0
文件: app.cs 项目: romanlum/StudyCode
    public static void Main(string[] args)
    {
        AdvCalc calc = new AdvCalc();

        Random rnd = new Random();

        for (int i = 0; i < 1000; i++)
        {
            calc.Add(rnd.NextDouble());
        }
        Console.WriteLine("Sum: {0}", calc.GetSum());
        Console.WriteLine("Average: {0}", calc.GetAverage());
    }
示例#2
0
    public static void Main(string[] args)
    {
        AdvCalc calc = new AdvCalc();

        Random r = new Random();
        for(int i = 0; i < 1000; i++)
        {
            calc.Add(r.NextDouble());
        }

        Console.WriteLine("Sum:     {0}", calc.GetSum());
        Console.WriteLine("Average: {0}", calc.GetAverage());
    }
    static void Main(string [] args)
    {
        AdvCalc calc = new AdvCalc();

        Random r = new Random();

        for (int i = 0; i < 1000; i++)
        {
            calc.Add(r.NextDouble());
        }

        Console.WriteLine($"sum: {calc.GetSum():F2}");       //neue Variante direkt in den Platzhalter den Code
        Console.WriteLine("avg: {0:F2}", calc.GetAverage()); //ältere Variante :F2 floating point number 2 NK
    }