Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <malloc.h>
  3.  
  4. typedef struct node {
  5. struct node *next;
  6. int value;
  7. } node;
  8.  
  9. node *numbers[1000000];
  10.  
  11. int calcHash(int value);
  12. void addNode(int index ,int value);
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16. FILE *input = fopen("input.txt", "r");
  17. FILE *output = fopen("output.txt", "w");
  18. int currNumber;
  19.  
  20. while (fscanf(input, "%d", &currNumber) != EOF)
  21. {
  22. fprintf(output, "%d ", calcHash(currNumber));
  23. printf("%d ", calcHash(currNumber));
  24. }
  25. getchar();
  26. return 0;
  27. }
  28.  
  29. int calcHash(int value)
  30. {
  31. return (value / 3169);
  32. }
  33.  
  34. void addNode(int index, int value)
  35. {
  36. if (numbers[index]) {
  37.  
  38. }
  39. else {
  40. numbers[index] = malloc(sizeof(node));
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement