Kumar
I am writing a c program for conversion of NFA to DFA
Kumar
Nfa stands for non deterministic finite automation
Kumar
Anyone help me plzz
Kumar
#include <stdio.h> #include <string.h>   #define STATES  256 #define SYMBOLS 20   int N_symbols;  int NFA_states; char *NFAtab[STATES][SYMBOLS];   int DFA_states; /* number of DFA states */ int DFAtab[STATES][SYMBOLS];   /*Print state-transition table.*/ void put_dfa_table(     int tab[][SYMBOLS], /* DFA table */     int nstates,    /* number of states */     int nsymbols)   /* number of input symbols */ {     int i, j;       puts("STATE TRANSITION TABLE");       /* input symbols: '0', '1', ... */     printf("     | ");     for (i = 0; i < nsymbols; i++) printf("  %c  ", '0'+i);       printf("\n-----+--");     for (i = 0; i < nsymbols; i++) printf("-----");     printf("\n");       for (i = 0; i < nstates; i++) {         printf("  %c  | ", 'A'+i);  /* state */         for (j = 0; j < nsymbols; j++)             printf("  %c  ", 'A'+tab[i][j]);         printf("\n");     } }   /*Initialize NFA table.*/ void init_NFA_table() { /*     NFA table for ex.21 at p.76       NFAtab[0][0] = "01";     NFAtab[0][1] = "0";     NFAtab[1][0] = "";     NFAtab[1][1] = "01";       NFA_states = 2;     DFA_states = 0;     N_symbols = 2; */ /*     NFA table for ex.17 at p.72 */     NFAtab[0][0] = "12";     NFAtab[0][1] = "13";     NFAtab[1][0] = "12";     NFAtab[1][1] = "13";     NFAtab[2][0] = "4";     NFAtab[2][1] = "";     NFAtab[3][0] = "";     NFAtab[3][1] = "4";     NFAtab[4][0] = "4";     NFAtab[4][1] = "4";       NFA_states = 5;     DFA_states = 0;     N_symbols = 2; }   /*String 't' is merged into 's' in an alphabetical order.*/ void string_merge(char *s, char *t) {     char temp[STATES], *r=temp, *p=s;       while (*p && *t) {         if (*p == *t) {             *r++ = *p++; t++;         } else if (*p < *t) {             *r++ = *p++;         } else             *r++ = *t++;     }     *r = '\0';       if (*p) strcat(r, p);     else if (*t) strcat(r, t);       strcpy(s, temp); }   /*Get next-state string for current-state string.*/ void get_next_state(char *nextstates, char *cur_states,     char *nfa[STATES][SYMBOLS], int n_nfa, int symbol) {     int i;     char temp[STATES];       temp[0] = '\0';     for (i = 0; i < strlen(cur_states); i++)         string_merge(temp, nfa[cur_states[i]-'0'][symbol]);     strcpy(nextstates, temp); }     int state_index(char *state, char statename[][STATES], int *pn) {     int i;       if (!*state) return -1; /* no next state */       for (i = 0; i < *pn; i++)         if (!strcmp(state, statename[i])) return i;       strcpy(statename[i], state);    /* new state-name */     return (*pn)++; }   /*     Convert NFA table to DFA table.     Return value: number of DFA states. */ int nfa_to_dfa(char *nfa[STATES][SYMBOLS], int n_nfa,     int n_sym, int dfa[][SYMBOLS]) {     char statename[STATES][STATES];     int i = 0;  /* current index of DFA */     int n = 1;  /* number of DFA states */       char nextstate[STATES];     int j;       strcpy(statename[0], "0");  /* start state */       for (i = 0; i < n; i++) {    /* for each DFA state */         for (j = 0; j < n_sym; j++) {    /* for each input symbol */             get_next_state(nextstate, statename[i], nfa, n_nfa, j);             dfa[i][j] = state_index(nextstate, statename, &n);         }     }       return n;   /* number of DFA states */ }   void main() {     init_NFA_table();     DFA_states = nfa_to_dfa(NFAtab, NFA_states, N_symbols, DFAtab);     put_dfa_table(DFAtab, DFA_states, N_symbols);   
Anonymous
#include <stdio.h> #include <string.h>   #define STATES  256 #define SYMBOLS 20   int N_symbols;  int NFA_states; char *NFAtab[STATES][SYMBOLS];   int DFA_states; /* number of DFA states */ int DFAtab[STATES][SYMBOLS];   /*Print state-transition table.*/ void put_dfa_table(     int tab[][SYMBOLS], /* DFA table */     int nstates,    /* number of states */     int nsymbols)   /* number of input symbols */ {     int i, j;       puts("STATE TRANSITION TABLE");       /* input symbols: '0', '1', ... */     printf("     | ");     for (i = 0; i < nsymbols; i++) printf("  %c  ", '0'+i);       printf("\n-----+--");     for (i = 0; i < nsymbols; i++) printf("-----");     printf("\n");       for (i = 0; i < nstates; i++) {         printf("  %c  | ", 'A'+i);  /* state */         for (j = 0; j < nsymbols; j++)             printf("  %c  ", 'A'+tab[i][j]);         printf("\n");     } }   /*Initialize NFA table.*/ void init_NFA_table() { /*     NFA table for ex.21 at p.76       NFAtab[0][0] = "01";     NFAtab[0][1] = "0";     NFAtab[1][0] = "";     NFAtab[1][1] = "01";       NFA_states = 2;     DFA_states = 0;     N_symbols = 2; */ /*     NFA table for ex.17 at p.72 */     NFAtab[0][0] = "12";     NFAtab[0][1] = "13";     NFAtab[1][0] = "12";     NFAtab[1][1] = "13";     NFAtab[2][0] = "4";     NFAtab[2][1] = "";     NFAtab[3][0] = "";     NFAtab[3][1] = "4";     NFAtab[4][0] = "4";     NFAtab[4][1] = "4";       NFA_states = 5;     DFA_states = 0;     N_symbols = 2; }   /*String 't' is merged into 's' in an alphabetical order.*/ void string_merge(char *s, char *t) {     char temp[STATES], *r=temp, *p=s;       while (*p && *t) {         if (*p == *t) {             *r++ = *p++; t++;         } else if (*p < *t) {             *r++ = *p++;         } else             *r++ = *t++;     }     *r = '\0';       if (*p) strcat(r, p);     else if (*t) strcat(r, t);       strcpy(s, temp); }   /*Get next-state string for current-state string.*/ void get_next_state(char *nextstates, char *cur_states,     char *nfa[STATES][SYMBOLS], int n_nfa, int symbol) {     int i;     char temp[STATES];       temp[0] = '\0';     for (i = 0; i < strlen(cur_states); i++)         string_merge(temp, nfa[cur_states[i]-'0'][symbol]);     strcpy(nextstates, temp); }     int state_index(char *state, char statename[][STATES], int *pn) {     int i;       if (!*state) return -1; /* no next state */       for (i = 0; i < *pn; i++)         if (!strcmp(state, statename[i])) return i;       strcpy(statename[i], state);    /* new state-name */     return (*pn)++; }   /*     Convert NFA table to DFA table.     Return value: number of DFA states. */ int nfa_to_dfa(char *nfa[STATES][SYMBOLS], int n_nfa,     int n_sym, int dfa[][SYMBOLS]) {     char statename[STATES][STATES];     int i = 0;  /* current index of DFA */     int n = 1;  /* number of DFA states */       char nextstate[STATES];     int j;       strcpy(statename[0], "0");  /* start state */       for (i = 0; i < n; i++) {    /* for each DFA state */         for (j = 0; j < n_sym; j++) {    /* for each input symbol */             get_next_state(nextstate, statename[i], nfa, n_nfa, j);             dfa[i][j] = state_index(nextstate, statename, &n);         }     }       return n;   /* number of DFA states */ }   void main() {     init_NFA_table();     DFA_states = nfa_to_dfa(NFAtab, NFA_states, N_symbols, DFAtab);     put_dfa_table(DFAtab, DFA_states, N_symbols);   
Use del.dog
Anonymous
hastebin.com
Anonymous
Why paste code here ;-;
Kumar
Use del.dog
I can't understand plz clarify it
Anonymous
Open that link : del.dog and paste your code there .. save it and then share link
Kumar
Ok sorry for sharing whole code here
Kumar
I need solution of that error anyone plzz help
Kumar
https://del.dog/
Was removed
Must i be good in programming so as to partipate in the group?🧐
Anonymous
https://del.dog/
paste the code there and save it(top right corner). then share the link
Kumar
https://del.dog/ocifujorew.cpp
Anonymous
https://del.dog/ocifujorew.cpp
256x20 is such a huge array
Anonymous
And I don't think you need it that big
Anonymous
👍
Anonymous
Any visual basic programming guru
theFlash
How to improve problem solving skills
theFlash
Anyone programs please suggest me
theFlash
Iam good at fundamentals if c language
theFlash
And can do some basic problems of array and srings and some more
theFlash
Please tell how should I improve
Yazan
here are some resourses: https://www.codeforces.com/ https://www.geeksforgeeks.org/ "good start to learn data structures and solve specific problems on them" "Introduction to Algorithms" 3d edition
theFlash
Any basic algorithms should I learn
theFlash
Any pre requirements for problem solving
theFlash
Like knowing any sorting and searching methods
theFlash
And like know some techniques
theFlash
Like count array 2 point method
Anonymous
How to improve problem solving skills
Try to achieve a balance between speed of the program and memory usage
theFlash
Yep but Iam not getting idea how to solve the problem for some questions
theFlash
How to start getting ideas
Yazan
read this book "Introduction to algorithms" 3d edition this will give you the basic fundamentials of problem solving using standard algorithms/data structures
Anonymous
How to start getting ideas
By not trying to get spoonfeeded and actually thinking
theFlash
Anonymous
👍
Yazan
then try to solve some problem on code forces/HackerRank/A2online judge using your own methods
theFlash
And is there any standard techniques for problem solving we should know
Yazan
and like @anunaym14 said, try to make your solutions as much efficiency as possible
Yazan
Good luck :)
theFlash
Tq bro's
theFlash
For your suggestions
Mike
Somebody knows podcast of c programming in english and in spanish?
Anonymous
hi guys
Anonymous
i am writing a configuration class which has 2 static methods. create and load.
Anonymous
both methods return an instance of the class
Anonymous
its not a singleton
Anonymous
the constructor of the class is private, so that you can only create an object of the config class by using create or load
Anonymous
Does that make sense?
Javier
I've always seen constructor in public declaration
Anonymous
the create method creates the configurstion and writes it to files. the load method loads the configuration from files to the internal data structure
Anonymous
yes, thats the intension
Anonymous
the class holds the global Configuration of the application.
Anonymous
and i dont like to use a singleton
Abode
nice to join you glad to be here 😇
Kenny
Someone can explain me Stings???
Alejandro
Great answer xD. I guess Kenny meant to say "Strings".
Top T : Trollface Was Real
+
Andrey
HI, we are looking for C++ Software developer with relocation to the Cyprus
Anonymous
LMFAO 😂😂
Aman Sharma
Isc
doesnt specify many things: can I pick it from 1 box only? then split by color and take only from the red box, can I look at the box when I pick? then i dont care of the boxes and just take red ones
quique
hi friends
quique
i need a expert in C/C++ for RSA implementation
Isc
i need a expert in C/C++ for RSA implementation
no, you dont need an expert, even a student can do it
quique
ok u can?
Isc
i already spoke with you
quique
hummmm maybe
PRAbHaT
which is best compiler for c++
Anonymous
which is best compiler for c++
https://youtu.be/yTAHfKGMOEM