reducing the width

This commit is contained in:
Jidong Xiao
2025-04-29 01:43:46 -04:00
committed by JamesFlare1212
parent 693b853865
commit 1ffe82c107

View File

@@ -380,7 +380,7 @@ function highlightIdentifyPath(index, path)
const mainCodeLines = const mainCodeLines =
[ [
'int main(){', 'int main(){',
' Node *phonebook[PHONEBOOK_SIZE] = {nullptr};', ' Node *phonebook[SIZE] = {nullptr};',
' add(phonebook, 5182764321, "dan");', ' add(phonebook, 5182764321, "dan");',
' add(phonebook, 6173551212, "fred");', ' add(phonebook, 6173551212, "fred");',
' add(phonebook, 5182761234, "alice");', ' add(phonebook, 5182761234, "alice");',
@@ -400,7 +400,7 @@ const funcCodeLines =
[ [
'#include <iostream>', '#include <iostream>',
'#include <string>', '#include <string>',
'const int PHONEBOOK_SIZE = 10;', 'const int SIZE = 10;',
'struct Node{', 'struct Node{',
'public:', 'public:',
' int number;', ' int number;',
@@ -409,9 +409,9 @@ const funcCodeLines =
' Node() : name(""), number(0), next(nullptr) {}', ' Node() : name(""), number(0), next(nullptr) {}',
'};', '};',
'int hash_function(int number){', 'int hash_function(int number){',
' return number % PHONEBOOK_SIZE;', ' return number % SIZE;',
'}', '}',
'void add(Node *phonebook[PHONEBOOK_SIZE], int number, const std::string &name){', 'void add(Node *phonebook[SIZE], int number, std::string &name){',
' int index = hash_function(number);', ' int index = hash_function(number);',
' Node *tmp = new Node;', ' Node *tmp = new Node;',
' tmp->name = name;', ' tmp->name = name;',
@@ -419,7 +419,7 @@ const funcCodeLines =
' tmp->next = phonebook[index];', ' tmp->next = phonebook[index];',
' phonebook[index] = tmp;', ' phonebook[index] = tmp;',
'}', '}',
'std::string identify(Node *phonebook[PHONEBOOK_SIZE], int number){', 'std::string identify(Node *phonebook[SIZE], int number){',
' int index = hash_function(number);', ' int index = hash_function(number);',
' Node *curr = phonebook[index];', ' Node *curr = phonebook[index];',
' while (curr != nullptr){', ' while (curr != nullptr){',
@@ -731,4 +731,4 @@ function highlightPersonBox(index, name, number, color)
group.add(nameText); group.add(nameText);
layer.add(group); layer.add(group);
layer.draw(); layer.draw();
} }