1、输出调试信息 else if (integers [i] marva county into oldIndices indices indices new int [count] oldIndices. Copy To (indices, 0) indices [count] return maxVal
6 1. 输出调试信息
1、输出调试信息 static void Main (str ingl args) int[] testArray=[4,7,4,2,7,3,7,8,3,9,1,9}; int[ maxVal Indices; int maxVal Max i ma (testArray out maxVal Indices) Writeline(S"数组中的最大数为{ maxVal},所在下标位置为:") foreach (int i in maxVal Indices) Write(s"i") ReadKey o 趿狙中的最天数为,所在下标位置为 911
7 1. 输出调试信息
1、输出调试信息 导入命名空间 using System. D i agnostics static int Max ima(int[ integers, out int[ indices Debug. Writeline("最大值搜索开始。"); indices new int[1] int maxVal integers [o] indices[O]= 0 int count =1 Debug. Writeline($"初始最大值为{ marVa},下标位置为0.") for ( int i =1: i< integers. Length; i++) Debug WriteLine( string. Format($"开始搜索第{i}个元素。")) if (integers[i]>maxVal) maxVal integers li] count =1 indices new int [1] indices[o]=i Debug. Wr ine($"发现新的最大值为{ marVa},下标位置为[i
导入命名空间 using System.Diagnostics; 8 1. 输出调试信息
1、输出调试信息 eI se if (integers li] marva 1) count++ nt oldIndices = indices indices new int [count] oldIndices. Copy To(indices, 0) dices [count -1] Debug. Write ine($"又发现一个最大值,下标位置为[i}."); Trace. WriteLine( string. Format($"最大值为{ marVa},共计有{ count}个。")) Debug. Writeline("最大值搜索结束!"); return maxVa
9 1. 输出调试信息
1、输出调试信息 0 utput窗口显示: 最大值搜索开始。 初始最大值为4,下标位置为0 开始搜索第1个元素 发现新的最大值为7,下标位置为1 开始搜索第2个元素。 开始搜索第3个元素。 开始搜索第4个元素。 又发现一个最大值,下标位置为4 开始搜索第5个元素 开始搜索第6个元素。 又发现一个最大值,下标位置为6 开始搜索第7个元素 发现新的最大值为8,下标位置为7 开始搜索第8个元素。 开始搜索第9个元素 发现新的最大值为9,下标位置为9 开始搜索第10个元素。 开始搜索第11个元素 又发现一个最大值,下标位置为11 最大值为9共计有2个 最大值搜索结束!
Output窗口显示: 10 1. 输出调试信息