Question: can anyone edit my code to printout the maximum-profit path in java? The maximum profit is 42. The maximum profit path is: (1,5) (2,4) (3,5)
can anyone edit my code to printout the maximum-profit path in java?
The maximum profit is 42. The maximum profit path is: (1,5) (2,4) (3,5) (4,5) (5,4)
p table
0 0 0 0 0 0 0 0 4 8 2 3 5 0 0 2 7 5 10 2 0 0 3 2 7 7 9 0 0 6 5 7 7 9 0 0 8 7 5 9 8 0
my code.
import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; import java.util.Stack;
public class MPPP1 { public static void computeQ(int[][] q,int[][] p, int[][] d) { int n = p.length; for (int j=1;j
// Open the file and read each integer one-by-one //System.out.print("if the file path is different, replace the file path in the code: "); //System.out.println(System.getProperty("user.dir")); Scanner scanner = new Scanner(new File("C:\\Users\\qq339\\eclipse-workspace\\test\\src\\test\\ptable.txt")); //Scanner scanner = new Scanner(new File("C:\\ptable.txt")); int[][] q = new int[6][7]; int[][] p = new int[6][7]; int[][] d = new int[6][7]; while (scanner.hasNextInt()) { for (int i=0;i<6;i++) { for (int j=0;j<7;j++) { p[i][j] = scanner.nextInt();}} } /* for (int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
