例如我有个txt文档d的内容如下
3
0
2
0, 0, 1
0, 1, 0
1, 0, 1
1, 1, 2
2,0,1
2,1,2
读取第一行并赋值给count
第二行赋值给ss
第三行赋值给fs
第四行起直至最后一行,设三位数分别为xyz,要将前两位数组成一个数组pair_d(x,y), 例如第四行为pair_d(0,0),z=1
第五行为pair_d(0,1),z=0 以此类推
当程序从别处读取的一个pair_w(x,y)与这里的pair_d(x,y)相同的时候,返回z
例如当程序从别处读取到pair_w(0,1)的时候,此程序需返回0
求问怎么将第四行起每一行的数字赋值才能在后面的程序实现上面的功能呢(因为有不同的文档d,虽然格式都一样但是里面的数字不一样,行数也不一样,有可能有第十一行比如3,0,2或者第十二行3,0,3,关键就是要读取每行的前两个数,并且通过比较前两个数xy返回不同第三个数z)我写到了读取第四行的方法的时候就不知道怎么将第四行赋予pair_d(x,y)并且让他们能和z有联系
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;class Automaton {
public static Automaton readAutomaton(String fileName) throws IOException{
int Count;
int ss;
int fs;
int[] automation = new int[3];
fileName = "input.txt";
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String tempString = null;
String Line1 = reader.readLine();
Count = Integer.parseInt(Line1);
String Line2 = reader.readLine();
ss = Integer.parseInt(Line2);
String Line3 = reader.readLine();
fs = Integer.parseInt(Line3); while ((tempString = reader.readLine()) != null) {
String[] tmp = tempString.split(", ");
//(从这里开始就不知道要怎么写了) } reader.close(); return null;
}
3
0
2
0, 0, 1
0, 1, 0
1, 0, 1
1, 1, 2
2,0,1
2,1,2
读取第一行并赋值给count
第二行赋值给ss
第三行赋值给fs
第四行起直至最后一行,设三位数分别为xyz,要将前两位数组成一个数组pair_d(x,y), 例如第四行为pair_d(0,0),z=1
第五行为pair_d(0,1),z=0 以此类推
当程序从别处读取的一个pair_w(x,y)与这里的pair_d(x,y)相同的时候,返回z
例如当程序从别处读取到pair_w(0,1)的时候,此程序需返回0
求问怎么将第四行起每一行的数字赋值才能在后面的程序实现上面的功能呢(因为有不同的文档d,虽然格式都一样但是里面的数字不一样,行数也不一样,有可能有第十一行比如3,0,2或者第十二行3,0,3,关键就是要读取每行的前两个数,并且通过比较前两个数xy返回不同第三个数z)我写到了读取第四行的方法的时候就不知道怎么将第四行赋予pair_d(x,y)并且让他们能和z有联系
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;class Automaton {
public static Automaton readAutomaton(String fileName) throws IOException{
int Count;
int ss;
int fs;
int[] automation = new int[3];
fileName = "input.txt";
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String tempString = null;
String Line1 = reader.readLine();
Count = Integer.parseInt(Line1);
String Line2 = reader.readLine();
ss = Integer.parseInt(Line2);
String Line3 = reader.readLine();
fs = Integer.parseInt(Line3); while ((tempString = reader.readLine()) != null) {
String[] tmp = tempString.split(", ");
//(从这里开始就不知道要怎么写了) } reader.close(); return null;
}
解决方案 »
- (char)( 97 & 1) + '0'); 看不懂,Unicode不是低两位吗?再说'0'重载过加号吗?
- jxl导入excel中日期格式问题
- Vector居然可以放基本数据类型,不是说不可以吗??
- 请问swing和applet不一样吗?
- 谁可以发给我head first java中文清晰版的电子书啊
- 关于对象的强,软,弱,虚引用在什么地方用啊
- 用JB做一个application,会自动生成两个文件,其中一个是***Frame1.java文件,难道所在的界面都要在这里写?
- 请问如何将String类型转化成Integer类型
- 一个简单的问题!
- 一个关于事件的问题
- java获取当前路径的问题
- java中都有哪些方法遍历set集合
当程序从别处读取的一个pair_w(x,y)与这里的pair_d(x,y)相同的时候,返回z
什么意思?
什么叫从别处读取一个那什么