Exemple #1
0
 public static Node add(Node[] linkhead) {
   Node sumhead = new Node(0);
   Node test = null;
   for (Node linkhead1 : linkhead) {
     Node temp = new Node(linkhead1.coeff);
     temp.expo = linkhead1.expo;
     test = linkhead1;
     while (test != null) {
       sumhead = (ordersort(sumhead, temp));
       test = test.next;
       if (test != null) {
         temp = new Node(test.coeff);
         temp.expo = test.expo;
       }
     }
   }
   return sumhead;
 }
Exemple #2
0
 public static Node convert(String temp) {
   Pattern p = Pattern.compile("[xX]\\^|\\*[xX]\\^");
   String[] temp1 = p.split(temp);
   Node p1 = null;
   for (int i = 0; i < temp1.length; i++) {
     int j = Integer.parseInt(temp1[i]);
     switch (i) {
       case 0:
         p1 = new Node(j);
         break;
       case 1:
         p1.expo = j;
         break;
     }
   }
   return p1;
 }