Python - java a python

 
Vista:

java a python

Publicado por de java a python (1 intervención) el 07/12/2022 00:19:56
me puede ayudar a convertir mi codigo java a python.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.io.*;
 
public class Main {
 
	public static void main(String args[]) throws IOException {
		BufferedReader bufEntrada = new BufferedReader(new InputStreamReader(System.in));
		int i;
		int j;
		int matrix[][];
		matrix = new int[3][3];
		for (i=2;i<=3;i++) {
			for (j=2;j<=3;j++) {
				if (i==3) {
					j = 3;
				}
				System.out.println("Escriba el numero: ");
				matrix[i-1][j-1] = Integer.parseInt(bufEntrada.readLine());
			}
		}
		if (matrix[2][0]==0) {
			for (i=3;i<=3;i++) {
				for (j=2;j>=1;j--) {
					System.out.println("Escriba el numero: ");
					matrix[i-1][j-1] = Integer.parseInt(bufEntrada.readLine());
				}
			}
		}
		if (matrix[1][0]==0) {
			for (i=2;i<=2;i++) {
				for (j=1;j>=1;j--) {
					System.out.println("Escriba el numero: ");
					matrix[i-1][j-1] = Integer.parseInt(bufEntrada.readLine());
				}
			}
		}
		if (matrix[0][0]==0) {
			for (i=1;i<=1;i++) {
				for (j=1;j<=3;j++) {
					System.out.println("Escriba el numero: ");
					matrix[i-1][j-1] = Integer.parseInt(bufEntrada.readLine());
				}
			}
		}
		for (i=1;i<=3;i++) {
			if (i>1) {
				System.out.println(" ");
			}
			for (j=1;j<=3;j++) {
				System.out.print(matrix[i-1][j-1]+"|");
			}
		}
		System.out.println(" ");
	}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder