fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. int main() {
  4. // Write C code here
  5. int longarray,i=0,s=0;
  6. bool tracker=true;
  7. int car;
  8. int Term[4][2]={{-1,1},{2,1},{2,3},{-1,1}};
  9. printf("Long of your cracter");
  10. scanf("%d",&longarray);
  11. char C[longarray];
  12. scanf("%s",C);
  13. while(i<longarray && tracker==true){
  14. car=C[i];
  15. i++;
  16. if(car!=1&&car!=0){
  17. tracker=false;
  18. }else{
  19. s=Term[s][car];
  20. if(s==-1){
  21. tracker=false;
  22. }
  23. }
  24. }
  25. if(tracker==true){
  26. printf("la chaine est acceptee");
  27. }else{
  28. printf("la chaine n est pas acceptee");
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 5288KB
stdin
45
stdout
Long of your cracterla chaine n est pas acceptee