Saturday, 29 August 2015

Hashcode example

#include "stdafx.h"
#include <iostream>
using namespace std;
int hashcode(int v)
{
  int l=0,s=0;
  while (v>0)
  {
   s+=v%10;
   v/=10;
   l++;

  }
return s;
}
int main()
{
cout<<hashcode(12345)<<endl;
system("pause");
return 0;
}

No comments:

Post a Comment