All pastes #2086123 Raw Edit

276

public text v1 · immutable
#2086123 ·published 2011-10-01 20:59 UTC
rendered paste body
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string.h>
using namespace std;

int Hasher (string & word) {
  int hash = 0;
  for (uint i = 0; i<word.length(); i++) {
    hash += (int) word[i] * (i+3);
  }
  hash = hash % 500;
  cout << hash << endl;
  return hash;
}

int main () {
  ifstream infile ("dictionary.txt");
  string word;
  while(infile.good() ) {
    getline(infile, word);
    Hasher(word);
  }
  return 0;
}