-4
public static void count(ArrayList<Double> list) {
if(list.empty()){
//how to do this **if list is null, return without doing anything **
}
//recursion function
if(total(list)>100){
/*
if total of list is more than 100, remove the first item and make a recursive call to count.
For example, if list = [40, 30, 80]=150, list should become [20, 80]=100
In the recursive function ,if the total of the array is greater than 100 ,using the function we have to remove one of any item and give a value that makes 100 with the rest of the numbers in the array.
if list = [40, 30, 80]=total is 150 ,so it is greater than 100
then list should become [20, 80]=100 (removed first two item and it replace by 20)
*/
}
}
注空の戻りです:合計のためのいずれかの方法を作るために 必要がありません私はまだ(ダブルトータルにこれを使用するものを作成しましたArrayListリスト)は、再帰関数の合計を呼び出します。アルゴリズムArrayListのための再帰関数のとArrayListのは、正確な配列
してください具体的な問題を明確にしたり、詳細を追加して必要なものを正確に強調したりできます。現在書かれているとおり、あなたが求めていることを正確に伝えるのは難しいです。この質問を明確にするために[** How to Ask page **](http://stackoverflow.com/help/how-to-ask)を参照してください。 –
まず、 'List'の合計をとるメソッドが必要です。 –
Rogue
あなたの質問は不明です。 [40、30、80] - > [20、80] –