从事先写好的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]
那位出来帮忙能下啊