###前提・実現したいこと
配列同士の演算結果をArrayListに格納し、その中での際で最大値をとるときの配列番号を求めたい。
###発生している問題・エラーメッセージ
参考にしたプログラムは機能するが、意味が理解できないので応用できない。
int c =-100;の果たす役割が知りたいです。
###該当のソースコード
int[] a = new int[]{1, 4, 2, 3, 4, 5}; int[] b = new int[]{2, 1, 5, 6, 7, 0}; ArrayList<Integer> sum = new ArrayList<Integer>(); int c =-100;//このコードの果たす役割がわからない int max = 0; for (int t = 0; t < a.length; t++) { sum.add((a[t] - b[t])); if (max < (a[t] - b[t])) { max = a[t] - b[t]; c = t; } sum.get(c) } System.out.println(c)
###試したこと
有限な配列の場合なら理解できる
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/01 04:52