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
|
int main()
{
int array[47] = { 19 , 11 , 7 ,4 , 4 ,6 , 9, 14, 18 ,20 ,20
, 17 , 13 , 9, 7 , 5, 3, 3, 2, 2 ,2 , 2 , 3, 3, 2, 2, 1,2 ,
4, 5,5,4,5,7, 10,11,9,6,5,7,14,20,21,16,11 ,5 , 1 };
double frmDiff[47];
int size=sizeof( array) /sizeof(int); //total size of array/size of arra
cout<< "size : " << size << endl;
for(int i = 0; i < size; i++)
{
frmDiff[i] = array[i] - array[i+1];
cout<< " array at index : " << i << " : "<< array[i]
<< " = " << " diff --> " << frmDiff[i] << endl;
}
cout<< " --------------------------------------------------- " << endl;
vector<int> aValues;
for(int j = 0; j < size; j++)
{
if ( frmDiff[j] == 0 )
{
if( j >= aValues.size() )
{
aValues.push_back(array[j]);
cout << aValues[j] << endl;
}
}
}
}
|