Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted by Kuba ( 13 years ago )
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXDLG 1024

int main(int argc, char *argv[])
{
  int stan_akceptowany = 1;
  int stan_poczatkowy = 3;

  int x;
  int i=0;
  char tasma[MAXDLG];
  typedef enum {q0=0, q1=1, q2=2, q3=3} stany;
  stany obecny_stan = 3;

  printf("Automat skonczony M=(Q, E, d, q0, F)\nQ={q0, q1, q2, q3}\nE={0, 1}\nF={q}\nq0 = q3\n");
  printf("Wprowadz tasme wejsciowa\n");

    int c;
    while ((c = getchar()) != '\n') {
        tasma[i] = c;
        i++;
    }
    int dlugosc_tasmy=i;

    printf("tasma[0]: %cx\n", tasma[0]);
    printf("dlugosc tasmy: %i\n", dlugosc_tasmy);


  for(i=0; i<dlugosc_tasmy ;i++) {
        printf("jestem na elemencie %i\n", obecny_stan);
        printf("teraz na tasmie: %c\n", tasma[i]);
        switch(obecny_stan) {
        case 3:
             switch(tasma[i]){
             case '0':obecny_stan=q1; break;
             case '1':obecny_stan=q2; break;
             //default:printf("Zly symbol wejsciowy!\n"); return 1;
             }
             break;
        case 2:
             switch(tasma[i]) {
             case '0':obecny_stan=q0; break;
             case '1':obecny_stan=q3; break;
             default:printf("Zly symbol wejsciowy!\n"); return 1;
             }
             break;
        case 1:
             switch(tasma[i]) {
             case '0':obecny_stan=q3; break;
             case '1':obecny_stan=q0; break;
             default:printf("Zly symbol wejsciowy!\n"); return 1;
             }
             break;
        case 0:
             switch(tasma[i]) {
             case '0':obecny_stan=q1; break;
             case '1':obecny_stan=q2; break;
             default:printf("Zly symbol wejsciowy!\n"); return 1;
             }
             break;

        //default:printf("Zly symbol wejsciowy!\n"); return 1;
        }
        }
        printf("obecny stan: %i\n", obecny_stan);
        printf("stan akceptowany: %i\n", stan_akceptowany);
        if (obecny_stan == stan_akceptowany)
           printf("Jezyk zaakceptowany!\n");
        else
            printf("Jezyk niezaakceptowany\n");


  system&#40;"PAUSE"&#41;;
  return 0;
}

 

Revise this Paste

Your Name: Code Language: