首页 > 其他 > 详细

实验五

时间:2019-04-07 19:25:41      阅读:129      评论:0      收藏:0      [点我收藏+]

public class shuchu{

public static void main(String[] args)

int i,j,a[];
a=new int[10];
System.out.println("a[]:");
for(i=0;i<10;i++) {
a[i]=sc.nextInt();
}
Arrays.sort(a,0,10);//
for(i=0;i<a.length;i++)
System.out.print(a[i]+" ");
System.out.print("\n");
System.out.println("sushu:");
for(i=0;i<a.length;i++) {
for(j=2;j<a[i];j++) {
if(a[i]%j==0)
break;
}

if(j>=a[i]&&a[i]>=2)
System.out.print(a[i]+" ");
}

}
}

实验结果:

9 8 7 6 5 4 3 2 1 0

2 3 5 7

实验心得:

       个人觉得排序输出比较简单一点点,,,而输出素数有点难。

实验五

原文:https://www.cnblogs.com/yanqianying1/p/10666497.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!