码迷,mamicode.com
首页 > 其他好文 > 详细

计算圆形、矩形、三角形的面积

时间:2015-05-10 12:35:02      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

class Progarm

{

static void Main(string[] argm)

{

Console.WriteLine("选择以下图形(输入图形序列号)");

Console.WriteLine("1、圆形,2、矩形,3、三角形);

string str = Console.ReadLine();

switch(str)

{

case "1":

  Console.WriteLine("请录入圆的半径:");

int  r = int.Parse(Console.ReadLine());

int yS = MG(r);

Console.WriteLine("圆的面积={0}",yS);

break;

case "2":

Console.WriteLine("请录入矩形的长:");

int c = int.Parse(Console.ReadLine());

Console.WriteLine("请录入矩形的宽:");

int k = int.Parse(Console.ReadLine());

int jS = MG(c, k);

Console.WriteLine("矩形的面积={0}",jS);

break;

case "3":

Console.WriteLine("请录入三角形的底长:");

int d = int.Parse(Console.ReadLine());

Console.WriteLine("请录入三角形的高:");

int g = int.Parse(Console.ReadLine());

int  x = 2;

int sS = MG(d, g, x);

Comsole.WriteLine("三角形的面积={0}",sS);

break;

}

}

static int MG(int r)

{

return Math.PI * r * r;

}

static int MG(int chang, int kuan)

{

return chang * kuan;

}

static int MG(int di, int gao, int x)

{

return di * gao / x;

}

}

计算圆形、矩形、三角形的面积

标签:

原文地址:http://www.cnblogs.com/gsj2ronger918/p/4492002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!