由4个变量(多组数据)决定一个值应该用什么方法求出每个变量对值的影响?

如题所述

3.编写一个程序,求三数的算术平均值,并在屏幕上输出。(变量)usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classProgram{publicvoidHM(intx,inty,intz){Console.WriteLine("{0},{1},{2}这三个数的算术平均数为{3}",x,y,z,(x+y+z)/3);}staticvoidMain(string[]args){intx,y,z;Programtest=newProgram();Console.WriteLine("请输入三个数");x=Int32.Parse(Console.ReadLine());y=Convert.ToInt32(Console.ReadLine());z=Int32.Parse(Console.ReadLine());test.HM(x,y,z);Console.Read();}}}4.已知圆的半径为2.5CM,求出该圆的直径、周长和面积。(表达式)usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classProgram{publicvoidHM(doubler){Console.WriteLine("直径为"+2*r);Console.WriteLine("周长为"+2*3.14*r);Console.WriteLine("面积为"+3.14*r*r);}staticvoidMain(string[]args){doubler;Programtest=newProgram();Console.WriteLine("请输入圆的半径");//2.5CMr=Convert.ToDouble(Console.ReadLine());test.HM(r);Console.Read();}}}5.编程实现从三个整数中选出最大和最小者,并显示输出。(条件运算符)usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classProgram{publicvoidHM(intx,inty,intz){if(x>y){if(y>z)Console.WriteLine("最大数为{0},最小数为{1}",x,z);elseif(xz){if(xz){if(z>x)Console.WriteLine("最大数为{0},最小数为{1}",y,x);}elseConsole.WriteLine("最大数为{0},最小数为{1}",z,x);这里的这些比较也可以用楼上的三目运算符会更加简单}staticvoidMain(string[]args){intx,y,z;Programtest=newProgram();Console.WriteLine("请输入要比较的三个数");x=Convert.ToInt32(Console.ReadLine());y=Convert.ToInt32(Console.ReadLine());z=Convert.ToInt32(Console.ReadLine());test.HM(x,y,z);Console.Read();}}}写的很粗糙希望你能够采纳!
温馨提示:答案为网友推荐,仅供参考