+ 3
How to split string and return the sum of every characters integer to the 31 to the power of i
In a hash table map suppose that key is a pointer of a character char *key, which is a string. Ho do we implement a function that returns split string and return the sum of every characters integer to the 31 to the power of i, where i starts from 0. For example if our char *key="abc"; k1=int(key[0]); k2=int(key[1]); k3=int(key[2]); result=k1+31*k2+k3*31^2; This function should be applied to the char *key="banana"; depending on the length of the characters.
5 Answers