0001 #include <cstdio> 0002 #include "_share/rand.h" 0003 #include "Bitmap/Bitmap.h" 0004 #include "Eratosthenes.h" 0005 #include "primeNLT.h" 0006 0007 int main(int argc, char* argv[]) { 0008 if (2 > argc) { printf("Usage: %s <maxInt>\n", argv[0]); return -1; } 0009 srand(31415926); //srand((uint32_t) time(nullptr)); //随机种子 0010 Rank n = atoi(argv[1]); //简化起见,不考虑非正的情况 0011 eratosthenes(n, PRIME_TABLE); 0012 for (Rank i = 0; i <= 13; i++) { //做13次随机测试(限于MAX_RAND,覆盖范围不超过0x7FFF) 0013 Rank low = dice(n); 0014 printf("The smallest prime number no less than %8d(%05X) is %8d\n", low, low, 0015 primeNLT(low, n)); 0016 } 0017 for (Rank i = 0; i < 13; i++) { //做13次等间距测试 0018 printf("The smallest prime number no less than %8d(%05X) is %8d\n", n*i/11, 0019 n* i / 11, primeNLT(n*i/11, n)); 0020 } 0021 return 0; 0022 }