Home   Cover Cover Cover Cover
 

Arrays von Tupeln

A03.cs
//===========================================================
// Arrays of tuples
// ----------------
// Create an array of measurement tuples.
// Compute and print mean values across all tuples.
//===========================================================

using System;

public class A3 {
  
  public static void Main() {
    
    //--- Create an array of measurement tuples
    (double, double)[] values = new (double, double)[] {
      (66.33, 08.65),
      (80.52, 07.93),
      (69.84, 06.61),
      (71.84, 09.00),
      (73.67, 07.83),
      (67.89, 08.24)
    };

    
    //--- Compute and print mean values across all tuples
    double sum1 = 0;
    double sum2 = 0;
    foreach (var tuple in values) {
      sum1 += tuple.Item1;
      sum2 += tuple.Item2;
    }
    Console.WriteLine("Mean values: {0:f2}, {1:f2}", sum1/values.Length, sum2/values.Length);
  }
}