import java.util.Scanner; public class NicoChester { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num = scan.nextInt(); checkNicoChester(num); } private static void checkNicoChester(int num) { int []result = new int[num]; int len = result.length-1; if(num%2 != 0){ for (int i = 0; i < len; i++) { result[i] = num*num-2*(result.length/2-i); System.out.print(result[i]+"+"); } System.out.print(num*num-2*(result.length/2-len)); } else{ for (int i = 0; i < len; i++) { result[i] = num*num-num+1+2*i; System.out.print(result[i]+"+"); } System.out.print(num*num-num+1+2*len); } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-10 17:29:25