C#基础篇十小练习02

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace P03
{
    
    class Program
    {
        static void Main(string[] args)
        {
            Test02();
        }
         public static void Test02()
        {
            /*2.写1个方法,接收接收圆的半径. 将圆的面积和周长返回,π取值3.14 圆的面积=π*半径的平方、圆的周长=π* 2*半径(10分) */
            Console.WriteLine("请输入圆的半径:");
            int half = Convert.ToInt32(Console.ReadLine());
            float[] arrResult = new float[2];
            Test02_01(half,arrResult);
            Console.WriteLine("半径为{0}圆圈的面积是{1},周长是{2}",half,arrResult[0],arrResult[1]);
            Console.ReadKey();
        }
        /// <summary>
        /// 计算周长和面积
        /// </summary>
        public static void Test02_01(int half,float[] arr)
       {
            arr[0] = 3.14f * half * half;
            arr[1] = 2 * 3.14f * half;
        }

    }
}

猜你喜欢

转载自blog.csdn.net/adsl3373056/article/details/80609441