#include<stdio.h>
#include<stdlib.h>
#include<time.h>
enum EntryType {Legitimate, Empty, Deleted};
struct HashEntry{
int Data;
enum EntryType Info;
};
struct HashTable{
int TableSize;
struct HashEntry * Cells;
};
struct HashTable *CreateTable() {
struct HashTable *H;
int i;
H =(struct HashTable*)malloc(sizeof(struct HashTable));
H->TableSize =101;
H->Cells =(struct HashEntry*)malloc(sizeof(struct HashEntry) * H->TableSize);
for (i = 0; i < H->TableSize; i ++)
H->Cells[i].Info = Empty;
return H;
}
int Hash(int K, int TableSize) {
int sum = 0;
return sum % TableSize;
}
int Find(struct HashTable *H, int K) {
int Pos, NewPos;
int CNum = 0;
Pos = Hash(K, H->TableSize);
NewPos = Pos;
while (H->Cells[NewPos].Info != Empty
&& H->Cells[NewPos].Data != K ) {
CNum ++;
NewPos = Pos + CNum;
if (NewPos >= H->TableSize)
NewPos %= H->TableSize;
}
return NewPos;
}
int FindX(struct HashTable *H, int K) {
int Pos, NewPos;
int CNum = 0;
Pos = Hash(K, H->TableSize);
NewPos = Pos;
while (H->Cells[NewPos].Info != Empty
&& H->Cells[NewPos].Data != K ) {
CNum ++;
NewPos = Pos + CNum;
if (NewPos >= H->TableSize)
NewPos %= H->TableSize;
}
if( H->Cells[NewPos].Data == K){
printf("%d\n",NewPos);
}else{
printf("not found");
}
}
void Insert(struct HashTable *H, int y) {
int Pos;
Pos = Find(H, y);
if (H->Cells[Pos].Info != Legitimate) {
H->Cells[Pos].Info = Legitimate;
H->Cells[Pos].Data = y;
}
}
int main(){
int i,j;
struct HashTable *H;
H=CreateTable();
srand((int)time(NULL));
for(i=0;i<100;i++){
Insert(H,rand()%101);
}
int x;
scanf("%d",&x);
FindX(H,x);
return 0;
}