public static string Thermocline(LakeClassArray A) { //double n = (LakeNepressing[1, 2] - LakeNepressing[0, 2]) /( LakeNepressing[1, 1] - LakeNepressing[0, 1]); //return (b.T - a.T) / (b.D - a.D); double Slope, MaxSlope = 0; double ThermoD1 = 0, ThermoD2 = 0; int i = 1, j = i + 1; while (j <= A.Array.GetUpperBound(0)) { Slope = Math.Abs((A.Array[j, 2] - A.Array[i, 2]) / (A.Array[j, 1] - A.Array[i, 1])); if (Slope > MaxSlope) { MaxSlope = Slope; ThermoD1 = A.Array[i, 1]; ThermoD2 = A.Array[j, 1]; } else { } i++; j++; } //double [] outputslope = new double [2] {ThermoD1,ThermoD2}; return "Epilimnion:= " + A.Array[0, 1] + "m - " + ThermoD1 + "m Thermocline:= " + ThermoD1 + "m and " + ThermoD2 + "m Hypoliminion:= " + ThermoD2 + "m and " + A.Array[A.Array.GetUpperBound(0), 1] + "m"; }
static void Main(string[] args) { double[,] LakeNepressing = new double[,] { {0,0,2.3,35}, {0,0,23,15}, {1,1,23,14}, {2,2,23,14}, {3,3,22,14}, {4,8,20,14}, {5,9,20,15}, {6,10,19,14}, {7,12,12,7}, {8,18,11,7}, {9,23,10,7}, {10,29,10,6}, }; LakeClassArray LakeNepressingA = new LakeClassArray(LakeNepressing, "LakeNepressing", 30, 45); Console.WriteLine(LakeClassArray.Thermocline(LakeNepressingA)); Console.WriteLine(LakeNepressingA); double[,] FishLake = new double[,] { {0,0,1.1,19}, {0,0,23,8}, {1,3,24,8}, {2,5,22,7}, {3,8,15,4}, {4,10,16,3}, {5,13,15,3}, {6,15,14,2}, }; LakeClassArray FishLakeA = new LakeClassArray(FishLake, "FishLake", 15, 2.3); Console.WriteLine(LakeClassArray.Thermocline(FishLakeA)); Console.WriteLine(FishLakeA); Console.ReadLine(); }