Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdlib.h>
- #include<time.h>
- using namespace std;
- void bubblesort( float the_array[], int arraySize)
- {
- for(int x=0; x<arraySize-1; x++) //sorting algorithm here
- {
- for(int y=0; y<arraySize-1; y++) //sorting algorithm here
- {
- if(the_array[y]>the_array[y+1])
- {
- float temp = the_array[y+1];
- the_array[y+1] = the_array[y];
- the_array[y] = temp;
- }
- }
- }
- }
- void printArray( float the_array[], int arraySize)
- {
- cout << " \n { ";
- for (int i = 0; i < arraySize; i ++)
- {
- if( i == arraySize - 1)
- cout << the_array[i];
- else cout << the_array[i] << ", " ;
- }
- cout << " } ";
- }
- int main()
- {
- int z = 0;
- int o = 1;
- float infinity = o /( o-o);
- float minus_infinity = -1 * infinity;
- float nan = (o-1)/(o-1);
- float minus_zero = -1*z;
- srand(time(NULL));
- float *emptyList = NULL;
- float oneList [] = {3.147678};
- float twoList[] = {34.164, 12.1};
- float longList[] = {1.32, 3.35, 4.97, 4.3215, 3.6457, 3.2798, 1.2457, 3.727678, 3.43457975, 0.124375, 6.3412478, 2.1219788}; // 12 elements
- float sameList[] = { 1.45, 1.58, 1.98 , 1.75, 1.97, 1.75, 1.69, 1.47, 1.45, 2.47, 1.32};
- //need to do arrays for +- inf, -0 and NaN
- float *randList = new float[150];
- for (int i = 0; i < 150; i ++)
- {
- randList[i] = pow((double)-1,(double)((rand()%2)+1))*((float)(rand()%1000000)/5353);
- }
- *int startTime = clock();
- bubblesort(oneList, 1); // example. will do this for each of the arrays itself.
- int endTime = clock() - startTime;
- printArray(oneList,1);
- cout << endTime;
- return 0;
- }
Add Comment
Please, Sign In to add comment