import java.util.*;
import java.io.*;
public class CountingChange {
public static int[] coin = {50, 25, 10, 5, 1};
public static long[] nway = new long[10000];
public static void main(String[] args) throws FileNotFoundException {
Scanner iFile = new Scanner(System.in);
int amount = iFile.nextInt();
nway[0] = 1;
for(int i = 0; i < coin.length; i++) {
int c = coin[i];
for(int j = c; j <= amount; j++)
nway[j] += nway[j-c]; // THIS ONE. WHAT'S THE USE OF THIS?
}
for(int i = 0; i <= amount; i++)
System.out.print(nway[i] + " ");
System.out.println();
System.out.println(nway[amount]);
}
}
So, I was wondering, what does the one with the comment do? I mean, what's the purpose of having that?
Thanks.

New Topic/Question
Reply




MultiQuote










|