#include <iostream>
usingnamespace std;
void main()
{
enum color {red, green, blue, yellow};
color A[99999];
int count = 0;
int N=0;
cout<<"Please enter the number of inputs: ";
cin>>N;
cout<<"Please enter the colors:\n";
for (int i=0; i<N; i++)
cin>>A[i];
for (int j=0; j<N; j++)
if (A[j] == A[j+1])
count++;
cout<<"There are " <<count <<" times where 2 consecutive colors are the same. ";
}
Thanks for the website, framework :)
But my problem is that i want to input the constants of the type 'color' itself, in an array, and I cannot do that...does someone know how to do that...but in simple terms (because it's just my second course in C++ xD)?
As the tip I gave you specifies, enumerated variables are constant. Therefore, enumerated values cannot be changed. The instance of color is pointless. Look at it this way: You have 99999 instances of color. The values of each element of the array cannot change their values because they are constant. In turn, all the values of each element remain the same.
Note this: If you do not assign a value to an enumerated variable, the compiler will assign a default one for you - leaving the variable initialized.