/*
 * Solution to Problem 1 (C++)
 * 12th Annual CS Programming Contest
 * WCU Dept of Math and CS
 * Copyright 2001 , All Rights Reserved
 *
 * Problem Statement:
 * Token Detector. 
 * This program prompts the user for a line of text and detects
 * whether the token "!=" exists within that line of text. 
 * The program will then output to the console whether or not it
 * found the token in the line of text. The line of text can 
 * be arbitrarily long; you cannot assume some maximum length
 * for the line of text. 
 *
 * The only part of the solution that is especially noteworthy
 * is that the case of "!!=" needs to be handled correctly. 
 * In particular, that the character after the first '!' is not
 * "=" does not mean that both characters should be discarded.
 * The second character might in fact be the start of the sought
 * for token.
 */

#include <iostream.h>

int main()
{
  bool tokenExists = false;
  char nextChar;

  cout << "Enter a sequence of characters (terminated by a ';'): " << endl;

  cin >> nextChar;
  while (nextChar != ';' && !tokenExists) {
    if (nextChar == '!') {
      cin >> nextChar;
      if (nextChar == '=')
        tokenExists = true;
    }
    else // the else is needed to handle the case of "!!="
      cin >> nextChar;  
  }
  if (tokenExists)
    cout << "The token exists." << endl;
  else
    cout << "The token does not exist." << endl;
}


