c#day01
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace testmysql { class Lianxi { //变量交换 const float PI = 3.14f; public void xiti1(int i ,int j){ Console.WriteLine("交换前:i="+i+" j="+j); int k; k = i; i = j; j = k; Console.WriteLine("交换后:i=" + i + " j=" + j); } //总分 平均分 public void xiti2(float csharp ,float unity, float math) { float score; float average; score = csharp + unity + math; average = score / 3; Console.WriteLine("总分为: "+score); Console.WriteLine("平均分为; "+average); } //圆的面积周长 public void xiti3(float r) { float area; float perimeter; area = PI * r * r; perimeter = 2 * PI * r; Console.WriteLine("圆的面积:"+area); Console.WriteLine("圆的周长:"+perimeter); } public void xiti4(float tshirt ,int tshirt_univalent,float pants, int pants_univalent ) { float total; float discount; total = tshirt *(float) tshirt_univalent; discount = total * 0.38f; Console.WriteLine("一共要付:{0}元",total); Console.WriteLine("打折后的价格为:{0}元",discount); } } /* class Maintests { static void Main(string[] args) { Lianxi liaxi = new Lianxi(); liaxi.xiti1(20,10); liaxi.xiti2(80,90,99); liaxi.xiti3(5); liaxi.xiti4(285,2,720,3); } }*/ }