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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#include <iostream>
#include <time.h> //to generate Random Numbers
using namespace std;
//Funtion Prototype
int loadArray ( int [], int);
void printArray (int [], int);
int split ( int[], int[], int);
int main ()
{
const int MAX_SIZE = 100;
int numbers [MAX_SIZE]; //Array size 100
int A, over50, sizeOver;
int size;
loadArray ( numbers, MAX_SIZE); //Calling loadArray function
printArray ( numbers, MAX_SIZE); //Calling printArray Function
final = split (numbers, size, MAX_SIZE);
cout << numbers << endl;
return 0;
}
//Functions
void printArray (int A[], int MAX_SIZE) //printArray Function
{
int i;
for ( i=0; i<MAX_SIZE; i++)
cout << A[i] << endl;
}
int loadArray ( int A[], int MAX_SIZE) //LoadArray Funciton
{
//fill with random numbers
int i,randomNumber;
srand (time (NULL) ); //Initialize random nubmer generator
for ( i=0; i < MAX_SIZE; i ++)
{
randomNumber = rand() % 100; // get random numbers; range 0-99
A[i]= randomNumber;
}
return 0;
}
int split ( int A[], int size, int MAX_SIZE)
{
int countA, countB;
countA = 0;
countB = 0;
for (int i = 0; i < 100; i++)
{
if (A[i] < 50)
{
for (int i=0; i< 99; i++)
{
while ( A[i] < 49 )
{
countA = i;
}
}
}
else
{
for (int i=0; i< 99; i++)
{
while ( A[i] < 49 )
{
countB = i;
}
}
}
}
return A[i];
}
|