Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- struct state{
- struct state *a;
- struct state *b;
- int numberOfState;
- int finall;
- };
- int add(int numberOfState, struct state *a, struct state *b int finall){
- if(h==NULL){
- h=(struct state*)malloc(sizeof(struct state));
- h->a=a;
- h->b=b;
- h->finall=0;
- h->numberOfState=numberOfState;
- return 0;
- }
- else if(value >= h->value){
- if(h->right!=NULL)
- add(value,h->right);
- else{
- h->right=(struct state*)malloc(sizeof(struct state));
- h->a=a;
- h->b=b;
- h->finall=0;
- h->numberOfState=numberOfState;
- return 0;
- }
- }
- else if(value < h->value){
- if(h->left!=NULL)
- add(value,h->right);
- else{
- h->left=(struct state*)malloc(sizeof(struct state));
- h->a=a;
- h->b=b;
- h->finall=0;
- h->numberOfState=numberOfState;
- return 0;
- }
- }
- }
- int move(struct state *current, char selection){
- return current->selection;
- }
- void main(){
- struct state *states[4];
- struct state *current;
- char control;
- String string;
- String stateMoves;
- struct state *states[0]=malloc;
- struct state *states[1]=malloc;
- struct state *states[2]=malloc;
- struct state *states[3]=malloc;
- add(0,states[1],states[2],0);
- add(1,states[2],states[3],0);
- add(2,states[2],states[2],1);
- add(3,states[3],states[3],0);
- current=state[0];
- do{
- control=getch();
- if(control=='a' || control=='b'){
- addToAnArray(stateMoves, current->numberOfState);
- addToAnArray(strings, control);
- current=move(current, control);
- }
- else
- printf("enter a valid move\n");
- }while(control!=32);
- for(i=0;i<strlen(moves))
- printf("%c",moves[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement