int INPUT(char *prompt, int low, int high); // Allowed in C++ void INPUT(char *prompt, char string[], int length); void PrintTitle(char *title); void PrintTitle(char *title) { // Function to print out title char buff[80]; // line on screen cout << endl; cout << "****************************************************************" << endl; cout << "* THE 15TH CALGARY REGION COMPUTER PROGRAMMING COMPETITION *" << endl; cout << "* JUNIOR HIGH SCHOOL *" << endl; cout << title << endl; cout << "* written by: Elaine Sin *" << endl; cout << "* date : June 14, 1995 *" << endl; cout << "****************************************************************" << endl; cout << endl; cout << " --- Press to continue:- "; // pause cin.getline(buff, 80); cout << endl; } int INPUT(char *prompt, int low, int high) { // Function to get input number from judge char buff[80]; // line of input int numvalid = 0; // number of valid number entred int num; // input number while (numvalid != 1) { cout << prompt << " range (" << low << "--" << high << ") "; // prompt cin.getline(buff, 80); // get input line numvalid = sscanf(buff, "%d\n", &num); // scan for an integer if (numvalid != 1) // if number entered is not an integer cout << "ERROR: number must be an number ... Try again" << endl; else if ((num < low) || (num > high)) { // if number is not in range cout << "ERROR: number not in range " << low << "- " << high << " ... Try again" << endl; numvalid = 0; } } return(num); // return input number } void INPUT(char *prompt, char string[], int length) { // Function to get an input line char buff[80]; // input line int i; // loop index cout << prompt << " "; // prompt for input cin.getline(buff, 80); // get input line for (i = 0; i < length; i++) string[i] = buff[i]; string[length] = '\0'; }