From 42c0cd0dd91c20102c367e5b44a17a19d9c10cf1 Mon Sep 17 00:00:00 2001 From: realstealthninja Date: Sat, 16 Aug 2025 04:59:48 +0000 Subject: [PATCH] Documentation for 63931308e48e0ab78f4d2061f8ffca082e50513b --- d9/d02/linear__search_8cpp.html | 107 ++++++++++++------------ d9/d02/linear__search_8cpp_source.html | 111 +++++++++++++------------ 2 files changed, 112 insertions(+), 106 deletions(-) diff --git a/d9/d02/linear__search_8cpp.html b/d9/d02/linear__search_8cpp.html index b1579c637..f4b6ccef5 100644 --- a/d9/d02/linear__search_8cpp.html +++ b/d9/d02/linear__search_8cpp.html @@ -217,49 +217,49 @@ Functions

Main function.

Returns
0 on exit
-

Definition at line 65 of file linear_search.cpp.

-
65 {
-
66 int mode = 0;
-
67
-
68 std::cout << "Choose mode\n";
-
69 std::cout << "Self-test mode (1), interactive mode (2): ";
+

Definition at line 68 of file linear_search.cpp.

+
68 {
+
69 int mode = 0;
70
-
71 std::cin >> mode;
-
72
-
73 if (mode == 2) {
-
74 int size = 0;
-
75 std::cout << "\nEnter the size of the array [in range 1-30 ]: ";
-
76 std::cin >> size;
-
77
-
78 while (size <= 0 || size > 30) {
-
79 std::cout << "Size can only be 1-30. Please choose another value: ";
-
80 std::cin >> size;
-
81 }
-
82
-
83 int *array = new int[size];
-
84 int key = 0;
+
71 std::cout << "Choose mode\n";
+
72 std::cout << "Self-test mode (1), interactive mode (2): ";
+
73
+
74 std::cin >> mode;
+
75
+
76 if (mode == 2) {
+
77 int size = 0;
+
78 std::cout << "\nEnter the size of the array [in range 1-30 ]: ";
+
79 std::cin >> size;
+
80
+
81 while (size <= 0 || size > 30) {
+
82 std::cout << "Size can only be 1-30. Please choose another value: ";
+
83 std::cin >> size;
+
84 }
85
-
86 // Input for the array elements
-
87 std::cout << "Enter the array of " << size << " numbers: ";
-
88 for (int i = 0; i < size; i++) {
-
89 std::cin >> array[i];
-
90 }
-
91
-
92 std::cout << "\nEnter the number to be searched: ";
-
93 std::cin >> key;
+
86 int *array = new int[size];
+
87 int key = 0;
+
88
+
89 // Input for the array elements
+
90 std::cout << "Enter the array of " << size << " numbers: ";
+
91 for (int i = 0; i < size; i++) {
+
92 std::cin >> array[i];
+
93 }
94
-
95 int index = LinearSearch(array, size, key);
-
96 if (index != -1) {
-
97 std::cout << "Number found at index: " << index << "\n";
-
98 } else {
-
99 std::cout << "Array element not found";
-
100 }
-
101 delete[] array;
-
102 } else {
-
103 tests(); // run self-test implementations
-
104 }
-
105 return 0;
-
106}
+
95 std::cout << "\nEnter the number to be searched: ";
+
96 std::cin >> key;
+
97
+
98 int index = LinearSearch(array, size, key);
+
99 if (index != -1) {
+
100 std::cout << "Number found at index: " << index << "\n";
+
101 } else {
+
102 std::cout << "Array element not found";
+
103 }
+
104 delete[] array;
+
105 } else {
+
106 tests(); // run self-test implementations
+
107 }
+
108 return 0;
+
109}
static void tests()
Self-test implementations.
int LinearSearch(int *array, int size, int key)
for IO operations
@@ -303,18 +303,21 @@ Functions
45 assert(LinearSearch(array, size, 1) == 1);
46 assert(LinearSearch(array, size, 2) == 2);
47
-
48 size = 6;
-
49 for (int i = 0; i < size; i++) {
-
50 array[i] = i;
-
51 }
-
52
-
53 assert(LinearSearch(array, size, 3) == 3);
-
54 assert(LinearSearch(array, size, 1) == 1);
-
55 assert(LinearSearch(array, size, 5) == 5);
-
56
-
57 std::cout << "All tests have successfully passed!\n";
-
58 delete[] array; // free memory up
-
59}
+
48 delete[] array;
+
49
+
50 size = 6;
+
51 array = new int[size];
+
52 for (int i = 0; i < size; i++) {
+
53 array[i] = i;
+
54 }
+
55
+
56 assert(LinearSearch(array, size, 3) == 3);
+
57 assert(LinearSearch(array, size, 1) == 1);
+
58 assert(LinearSearch(array, size, 5) == 5);
+
59
+
60 std::cout << "All tests have successfully passed!\n";
+
61 delete[] array; // free memory up
+
62}
diff --git a/d9/d02/linear__search_8cpp_source.html b/d9/d02/linear__search_8cpp_source.html index e4094be34..dd8d4970f 100644 --- a/d9/d02/linear__search_8cpp_source.html +++ b/d9/d02/linear__search_8cpp_source.html @@ -147,67 +147,70 @@ $(function(){initNavTree('d9/d02/linear__search_8cpp_source.html','../../','');
45 assert(LinearSearch(array, size, 1) == 1);
46 assert(LinearSearch(array, size, 2) == 2);
47
-
48 size = 6;
-
49 for (int i = 0; i < size; i++) {
-
50 array[i] = i;
-
51 }
-
52
-
53 assert(LinearSearch(array, size, 3) == 3);
-
54 assert(LinearSearch(array, size, 1) == 1);
-
55 assert(LinearSearch(array, size, 5) == 5);
-
56
-
57 std::cout << "All tests have successfully passed!\n";
-
58 delete[] array; // free memory up
-
59}
+
48 delete[] array;
+
49
+
50 size = 6;
+
51 array = new int[size];
+
52 for (int i = 0; i < size; i++) {
+
53 array[i] = i;
+
54 }
+
55
+
56 assert(LinearSearch(array, size, 3) == 3);
+
57 assert(LinearSearch(array, size, 1) == 1);
+
58 assert(LinearSearch(array, size, 5) == 5);
+
59
+
60 std::cout << "All tests have successfully passed!\n";
+
61 delete[] array; // free memory up
+
62}
-
60
-
-
65int main() {
-
66 int mode = 0;
-
67
-
68 std::cout << "Choose mode\n";
-
69 std::cout << "Self-test mode (1), interactive mode (2): ";
+
63
+
+
68int main() {
+
69 int mode = 0;
70
-
71 std::cin >> mode;
-
72
-
73 if (mode == 2) {
-
74 int size = 0;
-
75 std::cout << "\nEnter the size of the array [in range 1-30 ]: ";
-
76 std::cin >> size;
-
77
-
78 while (size <= 0 || size > 30) {
-
79 std::cout << "Size can only be 1-30. Please choose another value: ";
-
80 std::cin >> size;
-
81 }
-
82
-
83 int *array = new int[size];
-
84 int key = 0;
+
71 std::cout << "Choose mode\n";
+
72 std::cout << "Self-test mode (1), interactive mode (2): ";
+
73
+
74 std::cin >> mode;
+
75
+
76 if (mode == 2) {
+
77 int size = 0;
+
78 std::cout << "\nEnter the size of the array [in range 1-30 ]: ";
+
79 std::cin >> size;
+
80
+
81 while (size <= 0 || size > 30) {
+
82 std::cout << "Size can only be 1-30. Please choose another value: ";
+
83 std::cin >> size;
+
84 }
85
-
86 // Input for the array elements
-
87 std::cout << "Enter the array of " << size << " numbers: ";
-
88 for (int i = 0; i < size; i++) {
-
89 std::cin >> array[i];
-
90 }
-
91
-
92 std::cout << "\nEnter the number to be searched: ";
-
93 std::cin >> key;
+
86 int *array = new int[size];
+
87 int key = 0;
+
88
+
89 // Input for the array elements
+
90 std::cout << "Enter the array of " << size << " numbers: ";
+
91 for (int i = 0; i < size; i++) {
+
92 std::cin >> array[i];
+
93 }
94
-
95 int index = LinearSearch(array, size, key);
-
96 if (index != -1) {
-
97 std::cout << "Number found at index: " << index << "\n";
-
98 } else {
-
99 std::cout << "Array element not found";
-
100 }
-
101 delete[] array;
-
102 } else {
-
103 tests(); // run self-test implementations
-
104 }
-
105 return 0;
-
106}
+
95 std::cout << "\nEnter the number to be searched: ";
+
96 std::cin >> key;
+
97
+
98 int index = LinearSearch(array, size, key);
+
99 if (index != -1) {
+
100 std::cout << "Number found at index: " << index << "\n";
+
101 } else {
+
102 std::cout << "Array element not found";
+
103 }
+
104 delete[] array;
+
105 } else {
+
106 tests(); // run self-test implementations
+
107 }
+
108 return 0;
+
109}
static void tests()
Self-test implementations.
int LinearSearch(int *array, int size, int key)
for IO operations
-
int main()
Main function.
+
int main()
Main function.