Question
How do I get rid of the extra 4 at the end of the results? The actual input needs to match the expected input. Here
How do I get rid of the extra 4 at the end of the results? The actual input needs to match the expected input. Here is the code below:
#include
using namespace std;
void SelectionSort(int numbers[], int numbersSize) {
int i;
int j;
int k;
int temp;
for (i = 0; i
k = i;
for (j = i+1; j
if (numbers[j]
k = j;
}
}
temp = numbers[i];
numbers[i] = numbers[k];
numbers[k] = temp;
}
}
int main() {
int numbers[] = { 10, 2, 78, 4, 45, 32, 7, 11 };
const int NUMBERS_SIZE = 8;
int i;
cout
for (i = 0; i
cin >> numbers[i];
}
cout
cout
for (i = 0; i
cout
}
cout
SelectionSort(numbers, NUMBERS_SIZE);
cout
for (i = 0; i
cout
}
cout
return 0;
}
Test results: Test: 10 2 784 45 32 7 11 match Actual output Expected output 1 2 3 4 Enter eight unsorted numbers: UNSORTED: 10 2 78 445 32 7 11 SORTED: 2 4 7 10 11 32 45 78 W NP Enter eight unsorted numbers: UNSORTED: 10 2 78 445 32 7 11 SORTED: 2 4 7 10 11 32 45 78Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started