0
I am solving a paper on the problem of transportation. Only that all my entries are delimited by a ENTER
I would very much like to
1.read two integers (separated by space)
2.Give a ENTER
3.Read an nxm matrix formatted in the correct way;
I would also like to do this without using the Scanner class;
The code below:
package problemadotransporte;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class ProblemaDoTransporte {
public static class Cedula{
int noroesteDaCedula;
int valorDaCedula;
boolean boleano;
public void setValues()
{
Scanner entrada;
entrada = new Scanner(System.in);
this.noroesteDaCedula=entrada.nextInt();
}
}
public static void main(String[] args) throws IOException {
BufferedReader entrada = new BufferedReader(new InputStreamReader(System.in));
int n,m;
n=Integer.parseInt(entrada.readLine());
m=Integer.parseInt(entrada.readLine());
System.out.printf("%d %d",n,m);
Cedula[][] tableau = new Cedula[n][m];
for(int i=0;i<n;i++)for(int j = 0;j<m;j++)tableau[i][j]=new Cedula();
for(int i=0;i<n;i++){for(int j = 0;j<m;j++)tableau[i][j].setValues(); System.out.print("\n");}
}
}
The entrance you’re making:
2
2
2 21 1
1 1
1 1
1 1
The entrance that the teacher wants:
3 3
16 20 200
14 8 160
180 120 0
Got it? Something like:
inteiro inteiro
matriz de inteiroxinteiro
NOTE: I didn’t know how to assign a proper tag to this question, because they removed the JAVA TAG.