第一题
input.txt内放入1~10的整数10个
程序读取input.txt文件,把100个整数格纳入int型的配列a[100]
问:求各个数字被格纳多少个,表示结果
import java.io.*;public class Report2_2 { public static void main(String[] args) throws IOException{
String file;
if(args.length == 0){
file="input.txt";
}else{
file=args[0];
}
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr); int[] a = new int[100];
String s;
int index=0;
while((s = br.readLine()) != null && index<100){
a[index] = Integer.parseInt(s);
index++;
}
//////////////////
// 偙偙偐傜壓傪曇廤
//////////////////
}
}
已给出代码,只需在乱码部分下完成问题的操作即可,求助,小白百思不得其解
input.txt内放入1~10的整数10个
程序读取input.txt文件,把100个整数格纳入int型的配列a[100]
问:求各个数字被格纳多少个,表示结果
import java.io.*;public class Report2_2 { public static void main(String[] args) throws IOException{
String file;
if(args.length == 0){
file="input.txt";
}else{
file=args[0];
}
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr); int[] a = new int[100];
String s;
int index=0;
while((s = br.readLine()) != null && index<100){
a[index] = Integer.parseInt(s);
index++;
}
//////////////////
// 偙偙偐傜壓傪曇廤
//////////////////
}
}
已给出代码,只需在乱码部分下完成问题的操作即可,求助,小白百思不得其解