解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class Main {
public static int isprime(int X){
int flag = 0 ;
for(int i=2;i<=X;i++){
if(X%i==0&&X!=i)
break;
else if(i==X)
flag = 1 ;
}
return flag;
}
public static void main(String[] arg){
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
int n = sc.nextInt();
int sum = 0;
for(int X=m;X<=n;X++){
if(isprime(X)==1)
sum+=X;
}
System.out.print(sum);
}
}
0.0分
3 人评分
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:600 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:691 |
WU-蓝桥杯算法提高VIP-Quadratic Equation (C++代码)浏览:1742 |
WU-陶陶摘苹果2 (C++代码)浏览:967 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:526 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:468 |
IP判断 (C语言描述,蓝桥杯)浏览:1092 |
核桃的数量 (C语言代码)浏览:668 |
矩阵加法 (C语言代码)浏览:1719 |
1126题解浏览:577 |