文章
2
粉丝
65
获赞
2
访问
1.3k
/**
* 旋转方程
*
* @author Beyong
* @date 2024/01/27 22:25
**/
import java.util.*;
public class Poj1216 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[][] arr = new int[20][20];
int total_number = n * n;
int step = 1;
int xPos = 0;
int yPos = 0;
int flag = 0;
int loop_count = 1;
while (total_number != 0) {
arr[xPos][yPos] = step;
step++;
if(flag == 0) {
if(xPos == n - loop_count) {
flag = 1;
yPos++;
} else {
xPos++;
}
} else if(flag == 1) {
if(yPos == n - loop_count) {
flag = 2;
xPos--;
} else {
yPos++;
}
} else if (flag == 2) {
...
登录后发布评论
暂无评论,来抢沙发