文章目录 java-数组赋值java-交换最小完全平方数 java-数组赋值 int [] d = {88,99,100}; java-交换 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int s[] = new int[2]; s[0] = input.nextInt(); s[1] = input.nextInt(); int sw[] = new int[2]; sw = swap(s); System.out.println(sw[0] + " " + sw[1]); } public static int[] swap(int s[]) { int t; t = s[0]; s[0] = s[1]; s[1] = t; return s; } } 最小完全平方数 import java.util.*; /* * 输出大等于n的最小的完全平方数。 若一个数能表示成某个自然数的平方的形式,则称这个数为完全平方数 Tips:注意数据范围 * * */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Long n=sc.nextLong(); double t=Math.sqrt(n); long s=0; if(n<=0) s=0; else if((long)t*(long)t==n) s=n; else s=(long)t+1; System.out.println(s*s); } }