package 排序;
import java.util.Arrays;
public class Yh {
public static void main(String[] args)
{
int a[]= {1,17,24,21,7,9,8,10,3,14};
Arrays.sort(a);
System.out.print("排序输出:");
for(int m=0;m<10;m++)
System.out.print(" "+a[m]);
System.out.print("
");
System.out.print("素数: ");
for(int i=0;i<10;i++)
{
if(a[i]==0 && a[i]==1)
continue;
else if(a[i]/2>1 && a[i]%2==0)
continue;
else if(a[i]/3>1 && a[i]%3==0)
continue;
else if(a[i]/5>1 && a[i]%5==0)
continue;
else if(a[i]/7>1 && a[i]%7==0)
continue;
else
System.out.print(" "+a[i]);
}
System.out.println();
}
}
实验心得:
1:通过本次实验掌握了如何排序输出
2:更加熟悉了对素数含义的理解