私信TA

用户名:Praguetramp

访问量:29255

签 名:

等  级
排  名 19
经  验 19924
参赛次数 0
文章发表 130
年  龄 0
在职情况 待业
学  校
专  业

  自我简介:

aura

解题思路:

注意事项:

参考代码:

import java.util.Scanner;

/**
 * 2021年2月16日  下午8:32:46
 * @author praguetramp
 */
public class Main {

	public static void main(String []args) {
		Scanner in =new Scanner(System.in);
		int a=100,b=200,cnt=101;   //cnt计数
		String res ="";   //存储素数串
		for(int i=a;i<=b;i++) {
			boolean flag=true;
			for(int k=2;k<=Math.sqrt(i);k++) {
				if(i%k==0) {
					cnt--;
					flag=false;
					break;
				}
			}
			if(flag)
				res=res+i+" ";
		}
		System.out.println(cnt);
		System.out.println(res);
		in.close();
	}
}


 

0.0分

1 人评分

  评论区