Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
stack
//gcc 5.4.0 #include <stdio.h> #include <stdlib.h> #include <math.h> typedef struct nodo{ char tipo; int posX; int posY; struct nodo* pnext; }Nodo; void push(Nodo** ppstack, char valor, int x, int y){ Nodo *ptr = malloc(sizeof(Nodo)); ptr->tipo = valor; ptr->posX = x; ptr->posY = y; ptr->pnext = *ppstack; *ppstack = ptr; } void pop(Nodo** pptrStack){ Nodo *tmp = *pptrStack; *pptrStack = (*pptrStack)->pnext; free(tmp); } void Scan( char m[3][3],Nodo** pstack){ for ( int i= 0; i<3;i++){ for (int j=0; j<3;j++){ if( m[i][j] == 'X' || m[i][j] == 'O'){ push(pstack,m[i][j],i+1,j+1); } } } } int main(void) { Nodo *ptrStack = NULL; char m[3][3] = {{'X',' ', 'X'},{' ', 'O',' '},{'O','O',' '}}; Scan(m, &ptrStack); Nodo* paux = ptrStack; printf("%p",ptrStack); while(paux != NULL){ printf("{%c,%d,%d}",paux->tipo,paux->posX,paux->posY); paux = paux->pnext; } return 0; }
run
|
edit
|
history
|
help
0
Project 3 Part 1 v1.5
Rightleftjustfy
printing float 3 pointers
json string formatter
Command Expressions in Gnu C: What Does Return Return?
Score
B_141125_Repetidos
TeleBook2
time clock and day count through second by user input (ratneshgujarathi)
Sizeof void