C#--求圓的面積和周長

iamzxf發表於2015-03-24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace first
{
    class Program
    {
        static void Main(string[] args)
        {
            double radius;
            const double PI=3.14;

            Console.WriteLine("please input the radius:");
            if (double.TryParse(Console.ReadLine(), out radius))
            {
                double area, length;

                area = PI * radius * radius;
                length = 2 * PI * radius;

                Console.WriteLine("aera:{0},zhouchang:{1}", area, length);
            }
            else
                Console.WriteLine("input error");

            Console.ReadLine();
        }
    }
}

相關文章