数列 Array
Week 10 array function #include<iostream> #include<cmath> using namespace std; /* looking for prime within 100. Sieve of Eratosthenes algorithm */ int main() { int sum=0, a[100]={0}; for(int i=2;i<sqrt(100.0);i++) // outer loop for i[2,9] { sum=i; while(sum<100)// inner loop for sum[2,99] { sum=sum+i; if(sum<100) a[sum]=1; // why = ? } } for(int i=2;i<100;i++) { if(a[i]==0)cout<<i<<" "; // why == ? } cout<<""<<endl; return 0; } when a[i] = {9, 15} , how could we calculate and remove it from the array a[n]? ...