#include <stdio.h> #include <Windows.h> void init(char *data, int len) { unsigned int n = len * 8; char* p = NULL; for (unsigned int i = 0; i < n; i++) { if (i % 3 == 0) { p = data + i / 8; *p = *p | (1 << i % 8); } } } bool check(char* data, int len, int value) { char* p = data + value / 8; bool ret = *p & (1 << (value % 8)); return ret; } int main(void) { unsigned int n = 4000000000; int len = n / 8 + 1; char* data = (char*)malloc(len); memset(data, 0, len); init(data, len); while (1) { printf("请输入要监测的数:[输入-1退出]"); int value; scanf_s("%d", &value); if (value == -1) { break; } if (check(data, len, value)) { printf("%d在数据集合中\n", value); } else { printf("%d不在数据集合中\n", value); } } system("pause"); return 0; }