SlideShare a Scribd company logo
1 of 3
Download to read offline
/* M | 0 1 2 3 4 5 6 7
--------------------------
0 | 0 0 0 1 0 0 0 0
1 | 0 1 1 1 0 0 1 0
2 | 0 1 0 1 0 0 1 0
3 | 0 1 0 1 1 1 1 0
4 | 0 1 0 0 0 0 1 1
5 | 0 1 1 0 1 1 1 0
6 | 0 0 0 0 1 0 0 0
7 | 0 0 0 0 1 0 0 0
*/
#include <stdio.h>
#include <stdlib.h>
typedef struct LINKED_STACK_NODE_s *LINKED_STACK_NODE;
typedef struct LINKED_STACK_NODE_s {
LINKED_STACK_NODE next;
void *data;
} LINKED_STACK_NODE_t[1];
typedef struct LINKED_STACK_s {
LINKED_STACK_NODE head;
} LINKED_STACK_t[1], *LINKED_STACK;
typedef struct{
int R;
int C;
}POS_t[1], *POS;
int linked_stack_is_empty(LINKED_STACK stack) {
return stack->head == NULL;
}
LINKED_STACK linked_stack_init() {
LINKED_STACK stack = malloc(sizeof(LINKED_STACK_t));
stack->head = NULL;
return stack;
}
void linked_stack_push(LINKED_STACK stack, void *data) {
LINKED_STACK_NODE new = malloc(sizeof(LINKED_STACK_NODE_t));
if (new != NULL) {
new->data = data;
new->next = stack->head;
stack->head = new;
} else {
printf("Memory allocation error!n");
exit(0);
}
}
void *linked_stack_pop(LINKED_STACK stack) {
LINKED_STACK_NODE temp;
void *result = NULL;
if (stack->head != NULL) {
temp = stack->head;
stack->head = temp->next;
result = temp->data;
free(temp);
} else {
printf("Stack is emptyn");
exit(0);
}
return result;
}
void linked_stack_free(LINKED_STACK stack) {
while (stack->head != NULL) {
linked_stack_pop(stack);
}
free(stack);
}
void linked_stack_print2(LINKED_STACK s, int M[8][8]){
LINKED_STACK_NODE node = s->head;
while(node != NULL){
POS pos = (POS)node->data;
printf("(%d,%d)=%d ", pos->R, pos->C, M[pos->R][pos->C]);
node = node->next;
}
printf("n");
}
void solve_maze(){
int M[8][8] = {
/****** 0 1 2 3 4 5 6 7 */
/* 0 */ { 0, 0, 0, 1, 0, 0, 0, 0 },
/* 1 */ { 0, 1, 1, 1, 0, 0, 1, 0 },
/* 2 */ { 0, 1, 0, 1, 0, 0, 1, 0 },
/* 3 */ { 0, 1, 0, 1, 1, 1, 1, 0 },
/* 4 */ { 0, 1, 0, 0, 0, 0, 1, 1 },
/* 5 */ { 0, 1, 1, 0, 1, 1, 1, 0 },
/* 6 */ { 0, 0, 0, 0, 1, 0, 0, 0 },
};
int I, J, R = 0, C = 3;
// Write your code here!
}
int main(){
solve_maze();
return 0;
}

More Related Content

Similar to M 0 1 2 3 4 5 6 7 0.pdf

includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
galagirishp
 
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdfPlease finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
fortmdu
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
clarkjanyce
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
amitbagga0808
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
forladies
 
Im having difficulty with the directives i figured out a duplicatio.pdf
Im having difficulty with the directives i figured out a duplicatio.pdfIm having difficulty with the directives i figured out a duplicatio.pdf
Im having difficulty with the directives i figured out a duplicatio.pdf
maheshkumar12354
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
tienlivick
 
R57shell
R57shellR57shell
R57shell
ady36
 

Similar to M 0 1 2 3 4 5 6 7 0.pdf (20)

Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
 
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdfPlease finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
 
rrxv6 Build a Riscv xv6 Kernel in Rust.pdf
rrxv6 Build a Riscv xv6 Kernel in Rust.pdfrrxv6 Build a Riscv xv6 Kernel in Rust.pdf
rrxv6 Build a Riscv xv6 Kernel in Rust.pdf
 
Arp
ArpArp
Arp
 
Linked lists
Linked listsLinked lists
Linked lists
 
Vcs29
Vcs29Vcs29
Vcs29
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
Im having difficulty with the directives i figured out a duplicatio.pdf
Im having difficulty with the directives i figured out a duplicatio.pdfIm having difficulty with the directives i figured out a duplicatio.pdf
Im having difficulty with the directives i figured out a duplicatio.pdf
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
 
LLVM Backend の紹介
LLVM Backend の紹介LLVM Backend の紹介
LLVM Backend の紹介
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
 
R57shell
R57shellR57shell
R57shell
 
Double linked list
Double linked listDouble linked list
Double linked list
 
What is Linked List in C.docx
What is Linked List in C.docxWhat is Linked List in C.docx
What is Linked List in C.docx
 

More from ajay1317

The lemonade stands are perfectly competitive because A t.pdf
 The lemonade stands are perfectly competitive because A t.pdf The lemonade stands are perfectly competitive because A t.pdf
The lemonade stands are perfectly competitive because A t.pdf
ajay1317
 
Table Region .pdf
 Table Region  .pdf Table Region  .pdf
Table Region .pdf
ajay1317
 

More from ajay1317 (20)

0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdf0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdf
 
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
 
AIDS is a diagnostic term applied to HIVinfected persons .pdf
 AIDS is a diagnostic term applied to HIVinfected persons .pdf AIDS is a diagnostic term applied to HIVinfected persons .pdf
AIDS is a diagnostic term applied to HIVinfected persons .pdf
 
Three Theories of DNA Replication Who were the two scien.pdf
 Three Theories of DNA Replication  Who were the two scien.pdf Three Theories of DNA Replication  Who were the two scien.pdf
Three Theories of DNA Replication Who were the two scien.pdf
 
The lemonade stands are perfectly competitive because A t.pdf
 The lemonade stands are perfectly competitive because A t.pdf The lemonade stands are perfectly competitive because A t.pdf
The lemonade stands are perfectly competitive because A t.pdf
 
This program reads a decimal array and outputs each numb.pdf
 This program reads a decimal array and outputs each  numb.pdf This program reads a decimal array and outputs each  numb.pdf
This program reads a decimal array and outputs each numb.pdf
 
Two novice business students come to their professor and a.pdf
 Two novice business students come to their professor and a.pdf Two novice business students come to their professor and a.pdf
Two novice business students come to their professor and a.pdf
 
Un mtodo operativo para administrar el inventario es la i.pdf
 Un mtodo operativo para administrar el inventario es la i.pdf Un mtodo operativo para administrar el inventario es la i.pdf
Un mtodo operativo para administrar el inventario es la i.pdf
 
Table Region .pdf
 Table Region  .pdf Table Region  .pdf
Table Region .pdf
 
Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
 Supongamos que la Tierra gir hacia atrs pero an orbita.pdf Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
 
Synthesizes the new DNA strands in the 5 3 direction .pdf
 Synthesizes the new DNA strands in the 5 3 direction  .pdf Synthesizes the new DNA strands in the 5 3 direction  .pdf
Synthesizes the new DNA strands in the 5 3 direction .pdf
 
returns a new copy of the LinkedList It creates a copy .pdf
 returns a new copy of the LinkedList It creates a copy .pdf returns a new copy of the LinkedList It creates a copy .pdf
returns a new copy of the LinkedList It creates a copy .pdf
 
Sony Ericsson is a global company that was established in .pdf
 Sony Ericsson is a global company that was established in .pdf Sony Ericsson is a global company that was established in .pdf
Sony Ericsson is a global company that was established in .pdf
 
11 ST segment depression may indicate Ischemia Normal fin.pdf
 11 ST segment depression may indicate Ischemia Normal fin.pdf 11 ST segment depression may indicate Ischemia Normal fin.pdf
11 ST segment depression may indicate Ischemia Normal fin.pdf
 
Realice una investigacin adicional para obtener ms infor.pdf
 Realice una investigacin adicional para obtener ms infor.pdf Realice una investigacin adicional para obtener ms infor.pdf
Realice una investigacin adicional para obtener ms infor.pdf
 
Elvira es una pintora abstracta con un talento increble p.pdf
 Elvira es una pintora abstracta con un talento increble p.pdf Elvira es una pintora abstracta con un talento increble p.pdf
Elvira es una pintora abstracta con un talento increble p.pdf
 
Programming Assignment 4 Calculate the first 16 Fib.pdf
 Programming Assignment 4  Calculate the first 16 Fib.pdf Programming Assignment 4  Calculate the first 16 Fib.pdf
Programming Assignment 4 Calculate the first 16 Fib.pdf
 
El sndrome X frgil es un trastorno dominante ligado al s.pdf
 El sndrome X frgil es un trastorno dominante ligado al s.pdf El sndrome X frgil es un trastorno dominante ligado al s.pdf
El sndrome X frgil es un trastorno dominante ligado al s.pdf
 
In grading eggs into small medium and large the Nancy F.pdf
 In grading eggs into small medium and large the Nancy F.pdf In grading eggs into small medium and large the Nancy F.pdf
In grading eggs into small medium and large the Nancy F.pdf
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

M 0 1 2 3 4 5 6 7 0.pdf

  • 1. /* M | 0 1 2 3 4 5 6 7 -------------------------- 0 | 0 0 0 1 0 0 0 0 1 | 0 1 1 1 0 0 1 0 2 | 0 1 0 1 0 0 1 0 3 | 0 1 0 1 1 1 1 0 4 | 0 1 0 0 0 0 1 1 5 | 0 1 1 0 1 1 1 0 6 | 0 0 0 0 1 0 0 0 7 | 0 0 0 0 1 0 0 0 */ #include <stdio.h> #include <stdlib.h> typedef struct LINKED_STACK_NODE_s *LINKED_STACK_NODE; typedef struct LINKED_STACK_NODE_s { LINKED_STACK_NODE next; void *data; } LINKED_STACK_NODE_t[1]; typedef struct LINKED_STACK_s { LINKED_STACK_NODE head; } LINKED_STACK_t[1], *LINKED_STACK; typedef struct{ int R; int C; }POS_t[1], *POS; int linked_stack_is_empty(LINKED_STACK stack) { return stack->head == NULL; } LINKED_STACK linked_stack_init() { LINKED_STACK stack = malloc(sizeof(LINKED_STACK_t)); stack->head = NULL; return stack; } void linked_stack_push(LINKED_STACK stack, void *data) { LINKED_STACK_NODE new = malloc(sizeof(LINKED_STACK_NODE_t)); if (new != NULL) { new->data = data; new->next = stack->head; stack->head = new; } else { printf("Memory allocation error!n"); exit(0);
  • 2. } } void *linked_stack_pop(LINKED_STACK stack) { LINKED_STACK_NODE temp; void *result = NULL; if (stack->head != NULL) { temp = stack->head; stack->head = temp->next; result = temp->data; free(temp); } else { printf("Stack is emptyn"); exit(0); } return result; } void linked_stack_free(LINKED_STACK stack) { while (stack->head != NULL) { linked_stack_pop(stack); } free(stack); } void linked_stack_print2(LINKED_STACK s, int M[8][8]){ LINKED_STACK_NODE node = s->head; while(node != NULL){ POS pos = (POS)node->data; printf("(%d,%d)=%d ", pos->R, pos->C, M[pos->R][pos->C]); node = node->next; } printf("n"); } void solve_maze(){ int M[8][8] = { /****** 0 1 2 3 4 5 6 7 */ /* 0 */ { 0, 0, 0, 1, 0, 0, 0, 0 }, /* 1 */ { 0, 1, 1, 1, 0, 0, 1, 0 }, /* 2 */ { 0, 1, 0, 1, 0, 0, 1, 0 }, /* 3 */ { 0, 1, 0, 1, 1, 1, 1, 0 }, /* 4 */ { 0, 1, 0, 0, 0, 0, 1, 1 }, /* 5 */ { 0, 1, 1, 0, 1, 1, 1, 0 }, /* 6 */ { 0, 0, 0, 0, 1, 0, 0, 0 }, };
  • 3. int I, J, R = 0, C = 3; // Write your code here! } int main(){ solve_maze(); return 0; }