Advertisement
GamerBhai02

11. UID using Hashing

Jan 11th, 2025 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | Source Code | 0 0
  1. https://onlinegdb.com/jm_loagNp
  2. #include <stdio.h>
  3. unsigned int hash(const char *str) {
  4.     unsigned int hashValue = 0;
  5.     while (*str){
  6.         hashValue = hashValue * 31 + *str++;
  7.     }
  8.     return hashValue;
  9. }
  10. int main() {
  11.     char input[100];
  12.     printf("String: ");
  13.     scanf("%[^\n]", input);
  14.     printf("Unique Identifier for '%s': %u", input, hash(input));
  15.     return 0;
  16. }
Tags: Hashing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement