I don't know, but switch statements look like a lot.
I tried something like this:
CODE
bool isDanceWellFormed (string dance)
{
int beat;
char direction = 'L', 'l', 'D', 'd', 'U', 'u', 'R', 'r';
int number = '0', '1', '2', '3', '4', '5', '6', '7', '8', '9';
int i;
for (i = 0, i = inputsize (); i++)
int digit = input [i] - '0';
if (input [i] != '/'
|| input [i] != direction
|| input [i] != number) // checks to see if characters are /, number, or direction
cerr << "Error" << endl;
if ( (input [i] >= '0' && input [i] <= '9') || direction || '/' )
cerr << "Error" << endl;
int i;
for (i = 0, i = inputsize (); i++)
{
if (input [i] >= '0' && input [i] <= '9')
{
int digit = input [i] - '0';
if (j= i+1 && input [j]!= direction)
cerr << "Error";
for (j= i+2; j< i+2 + digit - 1; j++)
{
if (input [j] != "/")
cerr << "Error";
}
}
}
I'm trying to check that the string has characters that are either '/','a number', or a direction (D, R, U, L).
So anything wrong??