セクション 2. 章 8
single
Challenge: Find Maximum and Minimum in Array
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.
- In the
findMaxmethod, initialize themaxvariable with the first element of the array. - In the for loop, compare the current element with
max. - If the current element is greater, update
maxwith the current element. - Return the value of the
maxvariable. - In the
findMinmethod, initialize theminvariable with the first element of the array. - In the for loop, compare the current element with
min. - If the current element is smaller, update
minwith the current element. - Return the value of the
minvariable. - In the
mainmethod, call thefindMaxmethod with the correct parameter, pass thenumbersarray into it, and assign the result to themaxvariable. - In the
mainmethod, call thefindMinmethod with the correct parameter, pass thenumbersarray into it, and assign the result to theminvariable.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 2. 章 8
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください