标签:style class blog code http tar
static rt_uint32_t array1[ARRAY_LEN]; void func1(void) { for (rt_uint32_t i = 1; i <= ARRAY_LEN; i++) { array1[i - 1] = 0; } rt_uint32_t x, y = 0, z = 0; rt_uint32_t i = 0; for (x = 2; x <= ARRAY_LEN; x++) { y = 0; for (i = 1; i <= x; i++) { if (x % i == 0) { y++; } } if (y == 2) { z++; array1[x - 1] = x; } } array1[0] = 1; }
static rt_uint32_t array2[ARRAY_LEN]; void func2(void) { for (rt_uint32_t i = 1; i <= ARRAY_LEN; i++) { array2[i - 1] = 0; } rt_uint32_t x, y = 0, z = 0; rt_uint32_t i = 0; for (x = 3; x <= ARRAY_LEN; x++) { y = 0; for (i = 2; i <= x / 2; i++) { if (x % i == 0) { y++; break; } } if (y == 0) { z++; array2[x - 1] = x; } } array2[0] = 1; array2[1] = 2; }
static rt_uint32_t array3[ARRAY_LEN]; void func3(void) { for (rt_uint32_t i = 1; i <= ARRAY_LEN; i++) { array3[i - 1] = 0; } rt_uint32_t x, y = 0, z = 0; rt_uint32_t i = 0; for (x = 3; x <= ARRAY_LEN; x += 2) { y = 0; for (i = 2; i <= x / 2; i++) { if (x % i == 0) { y++; break; } } if (y == 0) { z++; array3[x - 1] = x; } } array3[0] = 1; array3[1] = 2; }
static rt_uint32_t array4[ARRAY_LEN]; void func4(void) { for (rt_uint32_t i = 1; i <= ARRAY_LEN; i++) { array4[i - 1] = 0; } rt_uint32_t x, y = 0, z = 0; rt_uint32_t i = 0; for (x = 3; x <= ARRAY_LEN; x++) { y = 0; for (i = 2; i <= sqrt(x); i++) { if (x % i == 0) { y++; break; } } if (y == 0) { z++; array4[x - 1] = x; } } array4[0] = 1; array4[1] = 2; }
static rt_uint32_t array5[ARRAY_LEN]; void func5(void) { for (rt_uint32_t i = 1; i <= ARRAY_LEN; i++) { array5[i - 1] = 0; } rt_uint32_t x, y = 0, z = 0; rt_uint32_t i = 0; for (x = 3; x <= ARRAY_LEN; x += 2) { y = 0; for (i = 2; i <= sqrt(x); i++) { if (x % i == 0) { y++; break; } } if (y == 0) { z++; array5[x - 1] = x; } } array5[0] = 1; array5[1] = 2; }
static rt_uint32_t array6[ARRAY_LEN]; void func6(void) { for (rt_uint32_t i = 1; i <= ARRAY_LEN; i += 2) { array6[i - 1] = i; } for (rt_uint32_t i = 3; i < sqrt(ARRAY_LEN); i+=2) { if (array6[i-1]) { for(rt_uint32_t j=i<<2;j<=ARRAY_LEN;j+=i) { array6[j] = 0; } } } array6[1] = 2; }
func1 | 2513922 |
func2 | 221563 |
func3 | 213926 |
func4 | 762945 |
func5 | 674993 |
func6 | 14663 |
标签:style class blog code http tar
原文地址:http://blog.csdn.net/utopiaprince/article/details/30475261