public class Test5 { public static void main(String[] args) { int j; for(int i= 2;i<=200;i++){ j=2; while (i%j!=0){ j++; if(i==j){ System.out.println(i); } } } } }
冒泡排序
public class demo{ public static void main(String[] args) { int[] numbers =new int[]{1,5,8,2,3,9,4}; int i ,j; for(i=0;i<numbers.length;i++){ for(j=0;j<numbers.length-1-i;j++){ if(numbers[j]<numbers[j+1]){ int tem = numbers[i]; numbers[j]=numbers[j+1]; numbers[j+1]=temp; } } } System.out.println("从大到小排序后的结果是:"); for(i=0;i<numbers.length;i++) System.out.print(numbers[i]+" "); } }