[英]How do I make this multi dimential array print the opposite numbers
So basically this Java program prints 所以基本上这个Java程序会打印
43
39
71
But I have to make it print 但是我必须把它打印出来
17
93
34
Currently I'm having a bit of trouble understanding it, if someone could show me a step by step on how to do this it would help a lot. 目前,我在理解它时遇到了一些麻烦,如果有人可以逐步向我展示如何做到这一点,将会很有帮助。
int a[][] = {{4,2,7}, {3,9,1}};
int j,i;
for(i = 0; i < a[0].length; i++)
{
for(j = 0; j < a.length; j++)
System.out.print(a[j][i]);
System.out.println();
}
Just reverse the order of the loops. 只需反转循环的顺序即可。
int a[][] = {{4,2,7},
{3,9,1}};
int j,i;
for(i = a[0].length - 1; i >= 0; i--)
{
for(j = a.length - 1; j >= 0; j--)
System.out.print(a[j][i]);
System.out.println();
}
您可以简单地反转循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.