Assignment 4
Another solution
using namespace std;
void computeLongestSequence(int arrayOfNumber[], int size)
{
int i, mode, count, temp_mode, temp_count;
mode = arrayOfNumber[0];
temp_mode = arrayOfNumber[0];
count = 1;
temp_count = 1;
for (i = 1; i < size; i++)
{
if (arrayOfNumber[i] == mode)
count++;
else
{
if (arrayOfNumber[i] == temp_mode)
temp_count++;
else
{
temp_mode = arrayOfNumber[i];
temp_count = 1;
}
}
if (temp_count == count)
mode = temp_mode;
}
cout << "Longest repeating number is: " << mode << " with count: " << count << endl;
}
A project dealing with c strings
Solution