题面
核心思想
贪心
最大 最小 次大 次小 ····· 这样就行了。
代码
import java.util.*;
public class Main {
public static void main(String[] args) {
final long MOD = (long) (1e9 + 7);
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] nums = new int[n];
int maxi = n, minn = 1;
for(int i = 0; i < n; i++){
if((i & 1) == 0)
nums[i] = maxi--;
else
nums[i] = minn++;
}
for(int i = 0; i < n; i++){
if(i == 0)
System.out.print(nums[i]);
else
System.out.print(" "+nums[i]);
}
}
}
标签:届秋招,scanner,真题,int,美团,nums,System,++
From: https://www.cnblogs.com/ganyq/p/18113568