Java 从向量中删除列<;向量<;短>&燃气轮机;
下面的函数必须删除我想要的行或列,删除行时一切正常,列中有一个错误。最后一个更新功能是更新文件Java 从向量中删除列<;向量<;短>&燃气轮机;,java,matrix,vector,Java,Matrix,Vector,下面的函数必须删除我想要的行或列,删除行时一切正常,列中有一个错误。最后一个更新功能是更新文件 public void deletefromfile() throws IOException { short mod; Scanner cin = new Scanner(System.in); System.out.println("0 - column "); System.out.println("
public void deletefromfile() throws IOException {
short mod;
Scanner cin = new Scanner(System.in);
System.out.println("0 - column ");
System.out.println("1 - row");
System.out.print(">>> ");
mod = cin.nextShort();
switch (mod) {
case 0:
// System.out.println("Number of column: ");
short col = cin.nextShort(); // column to be deleted
Short w;
for(int line = 0; line < A.size(); line++) {
w = A.get(lini).get(col); // w becomes the number in the required column
System.out.print(w + " "); // display the column to be deleted
A.remove(w); }
System.out.println();
System.out.println(A); // display the vector to see if it has been deleted
break;
//m--;
case 1:
System.out.println("Numarul randului: ");
short rand = cin.nextShort();
A.remove(rand);
System.out.println(A);
break;
default:
System.out.println("Introduceti un mod valid");
}
cin.close();
update();
}
public void deletefromfile()引发IOException{
短模;
扫描仪cin=新扫描仪(System.in);
System.out.println(“0-列”);
System.out.println(“1行”);
系统输出打印(“>>>”);
mod=cin.nextShort();
开关(mod){
案例0:
//System.out.println(“列数:”);
short col=cin.nextShort();//要删除的列
短w;
对于(int line=0;line
向量A;->向量声明(对不起我的英语)
我的档案是:
4.4
2941
9102514
19 18 35 1
1 2 3 8也许你应该使用A.remove(lini)。remove(col),而不是A.remove(w)?矩阵变成9 10 25 14 | 1 2 3 8我需要保留行数,减少列数。不管怎样,解决方案是:for(Vector vec:A)vec.remove(col);