Issue
I apologize for a rookie question. I am trying to run the Java programs in Eclipse given in the Algorithms, 4th edition book by Robert Sedgewick and Kevin Wayne: https://algs4.cs.princeton.edu/home/
I am having trouble with input arguments to the programs.
For example for the following program:
import java.util.Arrays;
public class BinarySearch
{
public static int rank(int key, int[] a)
{ // Array must be sorted.
int lo = 0;
int hi = a.length - 1;
while (lo <= hi)
{ // Key is in a[lo..hi] or not present.
int mid = lo + (hi - lo) / 2;
if (key < a[mid]) hi = mid - 1;
else if (key > a[mid]) lo = mid + 1;
else return mid;
}
return -1;
}
public static void main(String[] args)
{
int[] whitelist = In.readInts(args[0]);
Arrays.sort(whitelist);
while (!StdIn.isEmpty())
{ // Read key, print if not in whitelist.
int key = StdIn.readInt();
if (rank(key, whitelist) < 0)
StdOut.println(key);
}
}
}
The input arguments are:
% java BinarySearch tinyW.txt < tinyT.txt
I don't know where to pass input arguments in Eclipse. Any help will be appreciated.
Solution
Go in "Run configuration..." opening the menu of the play button.
You find what you need in arguments, environment tab and common. Actually common is the tab that you need.
Answered By - GDG612
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.