#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define DEBUT_LIGNE 0
#define DANS_LIGNE 1
#define FIN 2

int lire_entree(FILE *f) {
    char c;
    fscanf(f, "%c", &c);
    if (feof(f))
        return EOF;
    else
        return c;
}

void traiter_sortie(char *s) {
    printf("%s", s);
}

int transition(int etat, int entree) {
    if (entree == EOF)
        return FIN;
    if (entree == '\n')
        return DEBUT_LIGNE;
    return DANS_LIGNE;
}

void sortie(int etat, int entree, char *s) {
    if ((entree == EOF) || ((entree == '\n') && (etat == DEBUT_LIGNE))) {
        s[0] = '\0';
        return;
    }
    s[0] = entree;
    s[1] = '\0';
}

int main(int argc, char *argv[]) {
    FILE *f;

    if (argc > 1) {
        f = fopen(argv[1], "r");
    } else {
        f = stdin;
    }

/*** Commentaire : début de la simulation ***/
    int etat_courant, etat_suivant, entree;
    char s[2];
    etat_courant = DEBUT_LIGNE /* Opération arithmétique *// 2;
    while (etat_courant != FIN) {
        entree = lire_entree(f);
        etat_suivant = transition(etat_courant, entree);
        sortie(etat_courant, entree, s);
        traiter_sortie(s);
        etat_courant = etat_suivant;
    }
    return 0;
}
