C#语言 求4名同学三门成绩的平均值
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ConsoleApplication1 8 { 9 class Program 10 { 11 static float sum1 = 0, sum2 = 0, sum3 = 0; 12 static void Main(string[] args) 13 { 14 //for循环输入成绩 15 for (int i = 0; i < 4;i++ ) 16 { 17 Console.Write("Input English:"); 18 float m = float.Parse(Console.ReadLine()); 19 Console.Write("Input C#:"); 20 float c = float.Parse(Console.ReadLine()); 21 Console.Write("Input chinese:"); 22 float h = float.Parse(Console.ReadLine()); 23 24 sum1 = sum1 + m; 25 sum2 = sum2 + c; 26 sum3 = sum3 + h; 27 } 28 29 Console.Write("English:{0}", sum1 / 4); 30 Console.Write("C#:{1},", sum2 / 4); 31 Console.Write("chinese",sum3 / 4); 32 Console.Read(); 33 34 } 35 } 36 }