读取TXT文件实现集合运算

从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
[b]问题补充:[/b]
从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
我要全部代码,用JAVA实现,谢谢。
[b]问题补充:[/b]
从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
问题补充:
从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
最后解析式表达上有点困难
我只是学习中,不是工作。
请教大家了
谢谢。
[b]问题补充:[/b]
从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
问题补充:
从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
我要全部代码,用JAVA实现,谢谢。
问题补充:
从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
<strong>问题补充:</strong>
从事先写好的Input.txt文件中读取数,
Input.txt 内容
A{3,4,10,20,30,50}
B{1,2,34,5,6}
C{2,3,12,23,14,11}

用户在键盘随意输入,例如((A*B))+B-C,期中+,*,-,分别代表集合的并交差运算,控制台打印输出。
最后解析式表达上有点困难
我只是学习中,不是工作。
请教大家了
谢谢。
对于核心部分肯本没思路
[b]问题补充:[/b]
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class Math {

/**
 * @param args
 */
public static void main(String[] args) {
    int j = 0;
    int A[] = null, B[] = null, C[] = null;
    BufferedReader br = null;
    File file = new File("D:\\input.txt");
    try {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(
                file)));
        String str = null;
        while ((str = br.readLine()) != null) {
            String str2 = str.charAt(0) + "";
            String str1 = str.replace("{", "").replace("}", "").replace(
                    str2, "");
            String[] s = str1.split(",");
            int[] n = new int[s.length];
            for (int i = 0; i < s.length; i++) {
                n = Integer.parseInt(s);
            }
            if (j == 0) {
                A = n;
            } else if (j == 1) {
                B = n;
            } else {
                C = n;
            }
            ++j;
        }
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            br.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    int[] mer = subtraction(A, B);
    for (int i = 0; i < mer.length; i++) {
        System.out.print(mer + " ");
    }
}

// 求并集
public static int[] merger(int[] a, int[] b) {
    int n = a.length;
    int[] c = new int[a.length + b.length];
    for (int i = 0; i < a.length; i++) {
        c = a;
    }
    for (int i = 0; i < b.length; i++) {
        boolean isEqual = true;
        for (int j = 0; j < a.length; j++) {
            if (b == a) {
                isEqual = false;
                break;
            }
        }
        if (isEqual) {
            c[n++] = b;
        }
    }
    int d[] = new int[n];
    for (int i = 0; i < d.length; i++) {
        d = c;
    }

    return d;
}

// 求交集
public static int[] intersection(int[] a, int[] b) {
    int[] c = new int[a.length];
    int n = 0;
    for (int i = 0; i < a.length; i++) {
        for (int j = 0; j < b.length; j++) {
            if (a == b[j]) {
                c[n++] = a;
                break;
            }
        }
    }
    int[] d = new int[n];
    for (int i = 0; i < d.length; i++) {
        d = c;
    }
    return d;
}

// 求差
public static int[] subtraction(int[] a,int[]b) {
    int[] c = new int[a.length];
    int n = 0;
    for (int i = 0; i < a.length; i++) {
        boolean isDifference=true;
        for (int j = 0; j < b.length; j++) {
            if(a==b[j]){
                isDifference=false;
                break;
            }
        }
        if(isDifference){
            c[n++]=a;
        }
    }
    int d[]=new int[n];
    for(int i=0;i<d.length;i++){
        d=c;
    }
    return d;
}

}

谁能帮忙改下
[b]问题补充:[/b]
现在解析式表达很头疼啊
待人帮忙了

[b]问题补充:[/b]
那位出来帮忙能下啊

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class Math {

/** 
 * @param args 
 */ 
public static void main(String[] args) { 
    int j = 0; 
    int A[] = null, B[] = null, C[] = null; 
    BufferedReader br = null; 
    File file = new File("D:\\input.txt"); 
    try { 
        br = new BufferedReader(new InputStreamReader(new FileInputStream( 
                file))); 
        String str = null; 
        while ((str = br.readLine()) != null) { 
            System.out.println("str:"+str);
            String str2 = str.charAt(0) + ""; 
            System.out.println("str2:"+str2);
            String str1 = ((str.replace('{', ' ')).replace('}', ' ')).replace(str2.charAt(0), ' '); 
            String[] s = str1.split(","); 
            int[] n = new int[s.length]; 
            for (int i = 0; i < s.length; i++) { 
                n[i] = Integer.parseInt(s[i].trim()); 
            } 
            if (j == 0) { 
                A = n; 
            } else if (j == 1) { 
                B = n; 
            } else { 
                C = n; 
            } 
            ++j; 
        } 
    } catch (FileNotFoundException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
    } catch (IOException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
    } finally { 
        try { 
            br.close(); 
        } catch (IOException e) { 
            // TODO Auto-generated catch block 
            e.printStackTrace(); 
        } 
    } 
    int[] mer = subtraction(A, B); 
    for (int i = 0; i < mer.length; i++) { 
        System.out.print(mer[i] + " "); 
    } 
} 

// 求并集 
public static int[] merger(int[] a, int[] b) { 
    int n = a.length; 
    int[] c = new int[a.length + b.length]; 
    for (int i = 0; i < a.length; i++) { 
        c[i] = a[i]; 
    } 
    for (int i = 0; i < b.length; i++) { 
        boolean isEqual = true; 
        for (int j = 0; j < a.length; j++) { 
            if (b[i] == a[j]) { 
                isEqual = false; 
                break; 
            } 
        } 
        if (isEqual) { 
            c[n++] = b[i]; 
        } 
    } 
    int d[] = new int[n]; 
    for (int i = 0; i < d.length; i++) { 
        d[i] = c[i]; 
    } 

    return d; 
} 

// 求交集 
public static int[] intersection(int[] a, int[] b) { 
    int[] c = new int[a.length]; 
    int n = 0; 
    for (int i = 0; i < a.length; i++) { 
        for (int j = 0; j < b.length; j++) { 
            if (a[i] == b[j]) { 
                c[n++] = a[i]; 
                break; 
            } 
        } 
    } 
    int[] d = new int[n]; 
    for (int i = 0; i < d.length; i++) { 
        d[i] = c[i]; 
    } 
    return d; 
} 

// 求差 
public static int[] subtraction(int[] a,int[]b) { 
    int[] c = new int[a.length]; 
    int n = 0; 
    for (int i = 0; i < a.length; i++) { 
        boolean isDifference=true; 
        for (int j = 0; j < b.length; j++) { 
            if(a[i]==b[j]){ 
                isDifference=false; 
                break; 
            } 
        } 
        if(isDifference){ 
            c[n++]=a[i]; 
        } 
    } 
    int d[]=new int[n]; 
    for(int i=0;i<d.length;i++){ 
        d[i]=c[i]; 
    } 
    return d; 
} 

}

看《数据结构》——线性结构中的堆栈

[quote]我要全部代码,用JAVA实现,谢谢。 [/quote]

这种要法不好. 其他人给你个思路,活还是要自己做的..

如果别人把你的活都做了,你就失业了. :) 嘿嘿;

[quote]我要全部代码,用JAVA实现,谢谢。 [/quote]
呵呵你还真客气呢?干脆你把你的工资给我,我帮你做。

这个代码对于解析字符串来说,要写很多代码,我原来都有实现过这样的东西,就是解析一个配置好计算公式,利用堆栈的先进后出的原理,并要定义各个运算符的优先级.要自己定义好多的规则

你可以将你写的代码贴出来,我们可以帮你分析问题不能实现的原因,或者提点建议

再次提示:看《数据结构》——线性结构中的堆栈
这个和4则运算类似

这个只是改了一些小错误,你的逻辑上没错呀,你调一下看