1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int bubbleSort(const int nameofArray[], int incrementingList[], int arraySize);
int getMin(int test, int currentMin);
int main()
{
const int size = 5;
int x[size] = {5,4,6,1,8};
int y[size];
cout << x[size] << endl; //warning C4700: uninitialized local variable 'x' used
// (It was noted that I am initiallizing x[5] without that being
// a value, I'm looking to put an array here.)
y[size] = bubbleSort(x, y, size);
return 0;
}
int bubbleSort(const int nameofArray[], int incrementingList[], int arraySize)
//fixed line above (23) - error C2143: syntax error : missing ')' before ';'
// fixed still line above (23) - error C2059: syntax error : ')'
{ // fixed error C2470: 'arraySize' : looks like a function definition, , but there is no parameter list;
int smallestNumber = 10;
int placeHolder= 0;
int test = 0;
for (int i = 0;i < arraySize-1 ; i++)
{
test = nameofArray[i];
smallestNumber = getMin(test, smallestNumber);
incrementingList[i] = smallestNumber;
}
cout << incrementingList[arraySize] << endl ;
return incrementingList[arraySize];
}
int getMin(int test, int currentMin )
{
if(currentMin < test)
currentMin = test;
return currentMin;
}
|