c语言编程问题,初学者不太会,谢谢(*°"°)=3?

2024-11-28 15:53:24
推荐回答(1个)
回答1:

#include

void main() { int i,j,b,s,n;

scanf("%d",&n); s=0;

for ( i=2;i<=n;i++ ) {

b=1; for ( j=2;j<=i/2;j++ ) if ( i%j==0 ) { b=0;break; }

if ( b!=0 ) s+=i*i;

}

printf("%d\n",s);

}