请教下各位帅哥美女一个从m到n区间的所有素数求和并计算个数的编程问题?
#include<stdio.h>int main(){
int m=0, n=0, count=0, sum=0, isprime=1, i=0, j=0;
scanf("%d %d",&m, &n);
if(m=1){
m=2;
}
for(i=m;i<=n;i++){
for(j=2;j<=i-1;j++){
if(i%j==0){
isprime=0;
break;
}
}
if(isprime==1){
sum=sum+i;
count++;
}
}
printf("this is sum: %d, and this is count: %d\n", sum, count);
return 0;
}
这个是我的程序,下面是结果(不对呢?)
2 6
this is sum: 5, and this is count: 2
--------------------------------
Process exited after 6.559 seconds with return value 0
请按任意键继续. . .