/*
 * Arquivo: q1.c
 * -------------------
 * Este programa é uma solução da Questao 1 da primeira prova. 
 */
#include <stdio.h>
#include "genlib.h"
#include "simpio.h"

main()
{
    int n, x, xx, f, ff;
    bool inconsistente = FALSE;

    printf("Qual 'e o numero de numeros a serem lidos? ");
    n = GetInteger();
    printf("Primeiro numero? ");
    xx = GetInteger();
    printf("Proximo numero? ");
    x = GetInteger();
    n -= 2;

    if (xx < x) f = 1;
    else if (x == xx) f = 0;
    else f = -1;

    xx = x;
    while (n > 0) {
	printf("Proximo numero? ");
	x = GetInteger();
	n--;
	if (xx < x) ff = 1;
	else if (x == xx) ff = 0;
	else ff = -1;

	if (f == 0) f = ff;
	else if (f * ff < 0) {
	    inconsistente = TRUE;
	    break;
	}
	xx = x;
    }

    while (n > 0) {
	printf("Proximo numero? ");	
	x = GetInteger();
	n--;
    }

    if (inconsistente) printf("A sequencia nao 'e monotonica.\n");
    else if (f > 0) printf("A sequencia 'e crescente.\n");
    else if (f < 0) printf("A sequencia 'e decrescente.\n");
    else printf("A sequencia 'e constante.\n");
}
