最近在看看有意思的编程,发现算法真是一个好东西,呵呵,自己也写了一个简单的demo
代码具体如下:
#include <stdio.h> #include <string.h> #include <unistd.h> #include <stdint.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #define bSize 255 #define bufSize 4096 static uint64_t arr[255] ={0}; static uint64_t hash = 0; void whash(char *s) { int len = strlen(s); int i =0,total =0; while(i < len) { int index = s[i] -32; if((hash &(1 <<index)) ==0) { hash |= (1 <<index); arr[index]++; } else { arr[index]++; } i++; } } int bread(char *file) { int fd = open(file,O_RDONLY,0666); struct stat st; char buf[bufSize] = {'