22 for (
int i = 0; i < size; ++i) {
23 if (array[i] == key) {
39 int *array =
new int[size];
40 for (
int i = 0; i < size; i++) {
49 for (
int i = 0; i < size; i++) {
57 std::cout <<
"All tests have successfully passed!\n";
68 std::cout <<
"Choose mode\n";
69 std::cout <<
"Self-test mode (1), interactive mode (2): ";
75 std::cout <<
"\nEnter the size of the array [in range 1-30 ]: ";
78 while (size <= 0 || size > 30) {
79 std::cout <<
"Size can only be 1-30. Please choose another value: ";
83 int *array =
new int[size];
87 std::cout <<
"Enter the array of " << size <<
" numbers: ";
88 for (
int i = 0; i < size; i++) {
92 std::cout <<
"\nEnter the number to be searched: ";
97 std::cout <<
"Number found at index: " << index <<
"\n";
99 std::cout <<
"Array element not found";
static void tests()
Self-test implementations.
int LinearSearch(int *array, int size, int key)
for IO operations