ajout de nos fichiers
This commit is contained in:
64
Anna et Vincent/a.c
Normal file
64
Anna et Vincent/a.c
Normal file
@@ -0,0 +1,64 @@
|
||||
// Généré automatiquement à partir d'un automate reconnaissant le langage a.
|
||||
// Ensemble des états : {0, 1, 2}
|
||||
// État initiaux : {0}
|
||||
// États finaux : {1}
|
||||
// Transitions :
|
||||
// 0 -a-> 1
|
||||
// 1 -a-> 2
|
||||
// 2 -a-> 2
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main(void){
|
||||
int c, numline = 0;
|
||||
char *line = NULL;
|
||||
size_t linecap = 0;
|
||||
ssize_t linelen;
|
||||
while ((linelen = getline(&line, &linecap, stdin)) > 0){
|
||||
int state;
|
||||
numline++;
|
||||
state = 0;
|
||||
for (int k = 0; k < linelen; k++){
|
||||
c = line[k];
|
||||
switch (state){
|
||||
case 0:
|
||||
switch (c){
|
||||
case ('a'):
|
||||
state = 1;
|
||||
break;
|
||||
default:
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (c){
|
||||
case ('a'):
|
||||
state = 2;
|
||||
break;
|
||||
default:
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (c){
|
||||
case ('a'):
|
||||
state = 2;
|
||||
break;
|
||||
default:
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (false || state == 1 || state == 2){
|
||||
fprintf(stdout, "%4d: ", numline);
|
||||
fwrite(line, linelen, 1, stdout);
|
||||
fflush(stdout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user