我也是诶 楼主找到问题了么,是不是动态分配数组的问题
by TUming123 @ 2020-07-05 20:49:14
我的也是....
我的是本地全过 在线全RE
离谱
```java
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int size = input.nextInt();
int magicNumber = input.nextInt();
int[][] use = new int[size][size]; //获得基本数组 第一个是y轴,第二个是x轴
List<Magic> magics = new ArrayList<>();
for (int i = 0, s = 1; i < use.length; i++) {
for (int i1 = 0; i1 < use.length; i1++, s++) {
use[i][i1] = s;
}
} //初始填充
IntArray mainUse = new IntArray(use);
for (int i = 0; i < magicNumber; i++) {
magics.add(new Magic(input.nextInt(), input.nextInt(), input.nextInt(), input.nextInt()));
} //获得操作信息
for (Magic magic : magics) { //操作
int x = magic.getX();
int y = magic.getY();
int range = magic.getRange();
mainUse.sync(); //同步信息
for (int i = 0; i < range; i++){ //代表了第i层
for (int i1 = 0; i1 <= range*2 -1; i1++){ //代表了偏移量
if (magic.getWay() == 0){
//顺时针
mainUse.setInMain(x + range - i,y - range + i + i1, mainUse.getInBack(x - range + i + i1 ,y - range + i)); //左上角到右上角
mainUse.setInMain(x + range - i - i1,y + range - i, mainUse.getInBack(x + range - i,y - range + i + i1)); //右上角到右下角
mainUse.setInMain(x - range + i,y + range - i - i1, mainUse.getInBack(x + range - i - i1,y + range - i)); //右下角到左下角
mainUse.setInMain(x - range + i + i1,y - range + i, mainUse.getInBack(x - range + i,y + range - i - i1)); //左下角到左上角
} else {
mainUse.setInMain(x + range - i,y - range + i + i1, mainUse.getInBack(x + range - i - i1,y + range - i)); //左上角到右上角
mainUse.setInMain(x + range - i - i1,y + range - i, mainUse.getInBack(x - range + i,y + range - i - i1)); //右上角到右下角
mainUse.setInMain(x - range + i,y + range - i - i1, mainUse.getInBack(x - range + i + i1,y - range + i)); //右下角到左下角
mainUse.setInMain(x - range + i + i1,y - range + i, mainUse.getInBack(x + range - i,y - range + i + i1)); //左下角到左上角
}
}
}
}
printInt(mainUse);
}
private static void printInt(IntArray intArray) {
int[][] ints = intArray.getMain();
for (int[] anInt : ints) {
for (int i1 = 0; i1 < ints.length; i1++) {
System.out.print(anInt[i1] + " ");
}
System.out.print("\n");
}
} //打印数组
}
class Magic {
private final int x;
private final int y;
private final int range;
private final int way;
Magic(int x, int y, int range, int way) {
this.x = x - 1;
this.y = y - 1;
this.range = range;
this.way = way;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getRange() {
return range;
}
public int getWay() {
return way;
}
} //操作内容
class IntArray {
private final int[][] main;
private final int[][] back;
public IntArray(int[][] main) {
this.main = main;
this.back = new int[main.length][main.length];
for (int i = 0; i < main.length; i++) {
System.arraycopy(main[i], 0, back[i], 0, main.length);
}
}
public int[][] getMain() {
return main.clone();
}
public void sync() {
for (int i = 0; i < main.length; i++) {
System.arraycopy(main[i], 0, back[i], 0, main.length);
}
}
public int getInBack(int x, int y) {
return back[y][x];
}
public void setInMain(int x, int y, int value) {
main[y][x] = value;
}
}
```
by s_yh_china @ 2021-01-05 14:47:55
@[s_yh_china](/user/450620) 我觉得可能是oj不让用多个类,你试试把那几个类弄成内部类
by zlj0101 @ 2022-02-16 21:03:54
我也是全部re,这怎么测评呀我啥了
by guijianhongyan @ 2022-07-07 13:00:37
@[s_yh_china](/user/450620) 大佬解决了么,怎样才能测试过呀
by guijianhongyan @ 2022-07-07 13:09:29