进阶实验5-3.3 基于词频的文件相似度
自己花了一天的时间打出来的,本来想用C++的map做的,后来还是想着用哈希表慢慢敲完了…就当数据做PTA留个记录吧,挺好的。
我本来MAXSIZE设置的是实验指导上推荐的500009…然后交上去直接内存超限…(做了这么久第一次内存爆了),然后改成了50009就过了…
#include <stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<ctype.h>
#include <stdbool.h>
#define MAXSIZE 50009
#define MAXLEGTH 50
#define MAX 10
#define MIN 3
typedef struct Hash_information *Hash;
typedef struct Hash_information
{
char word[MAX+1];
bool Isfull;
}hash; //单个cell的个体,用数组存储
typedef struct file_information *File;
typedef struct file_information
{
int file;
int number;
double same;
Hash main;
}file_one;
File Input();//输入相关数据
void Insert(File file,Hash HashTable,const char stream[],const int legth);
int Get_number(const char stream[]); //获取字符映射的数字!
int Line_Search(const Hash HashTable,const char stream[],int reflect);
//返回第一个空位,如果找到空位前查到了与stream相同的数据流,返回-1表示之前已经有了
//使用的是线性探测!
void Output(File file);
void