All pastes #204722 Raw Edit

Someone

public text v1 · immutable
#204722 ·published 2006-10-16 05:21 UTC
rendered paste body
    public static void main( String[] args ) {

       String line[] = new String[10];
       String[] pairs = new String[2];
       Pair pairObj[] = new Pair[10];
       int lineCount=0;

       //make pairs empty 
       for(int i=1; i<pairs.length; i++) {
          pairs[i]=null;
       }

       //make line empty
       for(int i=1; i<line.length; i++) {
          line[i]=null;
       }

       //make pairObj empty
       for(int i=1; i<pairObj.length; i++) {
          pairObj[i]=null;
       }


       if(args.length<1){
          System.err.println("Wrong number of args");
          System.exit(1);
       }

       try {
          File file = new File(args[0]);
          Scanner scanner = new Scanner(file);
          while(scanner.hasNextLine()==true) {
             lineCount++;
             for (int i=1; i<=lineCount; i++) {
                try {
                   line[i]=scanner.next();
                }catch(NoSuchElementException nse) {
                   break;
                }
             }

          }
          scanner.close();
       }catch(FileNotFoundException e) {
          System.err.println("File isn't found" + e.getMessage());
          System.exit(1);
        }


       for(int i=1; i<=lineCount; i++) {
          pairs=line[i].split(",");
          pairObj[i]  = new Pair(Integer.parseInt(pairs[0]),Integer.parseInt(pairs[1]));
       }

       TreeMap<Pair,Integer> myMap = new TreeMap<Pair,Integer>();

       for(int i=1; i<=lineCount; i++) {
       myMap.put(pairObj[i],gcd(Integer.parseInt(pairs[0]),Integer.parseInt(pairs[1])));
       }

   }




} //GCDTable