ERATISTHENES Sieve Method

xiaoxiao2021-03-06  51

ERATISTHENES Sieve Method

Author: Unknown Source: Unknown

I use C methods and methods for mixing programming under TC. If you use Win-TC, you can compile this program directly. If you use TC2.0, you must compile yourself with the TCC editor yourself. Perhaps many people can use TC to embed compilation, they will feel compilation. When compiling, you need to copy all files in the directory in the TC to the current directory in the current directory, then use TCC-INCLUDE -LIB files in the current directory. Name can be. For example, the following procedure is in the file su.c, then you only need to use TCC -IINCLUDE -LIB SU command in the TC directory to compile this program. Of course, Win-TC is more convenient and can be compiled directly. / * Description: ERATOSTHENES screening method creates an array, in the following manner, in one mark: start from position 2, mark the position of all 2 to 1, then the same operation is performed on the number 3 after 2 This can find 5 after 3, then remember all 5 multiplexes, so you can find all the number of individuals in the array. Author: Flea Detective Date: 22/08 / 2004CopyRight: www.8623.com * / # ing #define n 100 # define Half N / 2VOID C_METHOD () / * C language method * / {INT F [N 1] = {0}, i, j, k; printf ("c method: / n"); f [0] = f [1] = 1; i = 2; while (i <= N / 2) {j = 2; while (1) {f [j * i] = 1; J ; IF ((j * i)> = n) Break;} for (k = i 1; k

转载请注明原文地址:https://www.9cbs.com/read-87863.html

New Post(0)