Write a function that will read one line of input from the terminal. The input is supposed to consist of two parts separated by a colon \(\texttt{:}\).

As its result, your function should produce a single character as follows:

\(
\begin{array}{c l }
\texttt{N} & \texttt{No colon on the line}.\\
\texttt{L} & \texttt{The left part (before the colon) is longer than the right}.\\
\texttt{R} & \texttt{The right part (after the colon) is longer than the left}.\\
\texttt{D} & \texttt{The left and right parts have the same length but are different}.\\
\texttt{S} & \texttt{The left and right parts are exactly the same}.\\
\end{array}
\)

Examples
\(\begin{array}{l c }
\textbf{Input} & \textbf{Output}\\ \hline
Sample Sample & N\\
Left:Right & R\\
Sample:Sample & S\\
\end{array}\)


Use a queue to keep track of the left part of the line while reading the right part.


Difficulty level
Video recording
This exercise is mostly suitable for students
char out (char *str)
{
	char *p=str;
	element e;
	int found = 0, equal = 1;
	queue q=CreateQueue();

	while(*p!='\0' && !found)
	{
		if(*p==':')
		{
			found=1;
			p++;
			break;
		}
		EnQueue(&q,*p);
		p++;
	}

	if(found==1)
	{
		while(*p!='\0' && Front(q,&e))
		{
			DeQueue(&q);
			if(*p!=e && equal==1)
				equal=0;
			p++;
		}

		if(*p!='\0')
			return 'R';
		if(Front(q,&e))
			return 'L';
		if(equal==1)
			return 'S';
		else
			return 'D';

	}
	return 'N';
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Decimal to binary