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++) {
51 array =
new int[size];
52 for (
int i = 0; i < size; i++) {
60 std::cout <<
"All tests have successfully passed!\n";
71 std::cout <<
"Choose mode\n";
72 std::cout <<
"Self-test mode (1), interactive mode (2): ";
78 std::cout <<
"\nEnter the size of the array [in range 1-30 ]: ";
81 while (size <= 0 || size > 30) {
82 std::cout <<
"Size can only be 1-30. Please choose another value: ";
86 int *array =
new int[size];
90 std::cout <<
"Enter the array of " << size <<
" numbers: ";
91 for (
int i = 0; i < size; i++) {
95 std::cout <<
"\nEnter the number to be searched: ";
100 std::cout <<
"Number found at index: " << index <<
"\n";
102 std::cout <<
"Array element not found";
static void tests()
Self-test implementations.
int LinearSearch(int *array, int size, int key)
for IO operations