构建时出现错误(获得所需结果之后)。
0x7fff6acd623e <+10>:jae 0x7fff6acd6248; <+20>
可能是什么问题?
#include <stdio.h>
int main()
{
int arr[100], i, j = 2, jump, k, sum =0 ;
for (i = 0; i < 100; i++) //input numbers from 2 -> to limit of arrSize
arr[i] = j++;
for (i = 0; i < 100; i++) //if the value of arr[i] isnt already = 0, then jump
{ //will get the value of i (e.g. 3), and jump 3 steps,
if (arr[i] != 0) //not including 0 values.
{
jump = arr[i];
for (k = jump; k < 100; k+=jump) //then it will assign value 0.
arr[i+k] = 0;
}
else
continue; //if arr[i] = 0, it will go to the next iteration
}
for (i = 0; i < 100; i++) //print all numbers. the not-prime will be 0.
printf("%d\n ", arr[i]); //it can be improved by copying not 0 values to other arr
//but for summing up it don't make any different.
}