CCF旋转图像之旋转矩形

CCF旋转图像之旋转矩形

在这里插入图片描述
代码思路:1、就是简单的俩个二数组,然后交换里面的数据。
2、学会了System.out.print(arr2[i][j]+" ");这种在终端输出的样子,
3、学会了用测试的思想来检验代码的正确性。
4、但是还是不知道怎么看有没有超内存!!!
代码如下:
package algorithm_text;

import java.util.Scanner;

/**

  • 目标实现:就是图形旋转:
  • @author Lenovo

*/

public class Graphic_rotation {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int arr[][] = null;
arr = new int[n][m];
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
arr[i][j] = sc.nextInt();
}
}
// 验证二维数组是不是插入成功
// for(int i=0;i<n;i++) {
// for(int j=0;j<m;j++) {
// System.out.print(arri[i][j]+" “);
// }
// }
int arr2[][] = new int[m][n];
for(int i=0;i<m;i++) {
System.out.println( );
for(int j=0;j<n;j++) {
arr2[i][j] = arr[j][i];
System.out.print(arr2[i][j]+” ");
}
}
}
}

猜你喜欢

转载自blog.csdn.net/hailiang9615/article/details/88136923