Debug记录(更新:Valgrind: Conditional jump or move depends on uninitialized value(s))
Valgrind: Conditional jump or move depends on uninitialized value(s)
相同的hashcode
最后更新于
最后更新于
Node* appendNode(Node* head, int v) {
if (head == NULL) {
return NULL;
}
Node* p = head;
while (p->next != NULL) {
p = p->next;
}
// bad style
p->next = (Node *)malloc(sizeof(Node));
p = p->next;
p->data = v;
p->next = NULL;
return p;
}Node *node = (Node *)malloc(sizeof(Node));
node->data = v;
node->next = NULL;
p->next = node;public static int hashCode(int[] array) {
int total = 0;
for (int element : array) {
total = total * 256;
total = total + element;
}
return total;
}
public static void main(String[] args) {
int[] array1 = {80, 103, 142, 91, 160, 250, 7, 7, 7, 7};
int[] array2 = {130, 105, 209, 7, 7, 7, 7};
int hashCode1 = hashCode(array1);
int hashCode2 = hashCode(array2);
System.out.println("hashCode1: " + hashCode1);//117901063
System.out.println("hashCode2: " + hashCode2);//117901063
}