int main() { /*Driver code to test the implementation*/ head = NULL; // empty list. set head as NULL. // Calling an Insert and printing list both in forward as well as reverse direction. InsertAtTail(2); Print(); ReversePrint(); InsertAtTail(4); Print(); ReversePrint(); InsertAtHead(6); Print(); ReversePrint(); InsertAtTail(8); Print(); ReversePrint(); }
void ReversePrint(Node *head) { if (head) { ReversePrint(head->next); printf("%d\n", head->data); } }
void ReversePrint(Node *head) { // This is a "method-only" submission. // You only need to complete this method. if(!head) return; ReversePrint(head->next); cout << head->data << endl; }
void ReversePrint(Node *head) { // This is a "method-only" submission. // You only need to complete this method. if (head) { ReversePrint(head->next); printf("%d\n", head->data); } }
/* Print elements of a linked list in reverse order as standard output head pointer could be NULL as well for empty list Node is defined as struct Node { int data; struct Node *next; } */ void ReversePrint(Node *head) { if(head == NULL) return; ReversePrint(head->next); cout << head -> data << endl; }
/* Print elements of a linked list in reverse order as standard output head pointer could be NULL as well for empty list Node is defined as struct Node { int data; struct Node *next; } */ void ReversePrint(Node *head) { Node *currentNode = head; if(currentNode == NULL){ return; } ReversePrint(currentNode->next); cout <<currentNode->data<<endl; }
//test recursive call in printing node void ReversePrint(Node *p) { if(p == NULL) //tail { return; } //printf("%d ", p->data); ReversePrint(p->next); printf("%d ", p->data); }
/* Print elements of a linked list in reverse order as standard output head pointer could be NULL as well for empty list Node is defined as struct Node { int data; struct Node *next; } */ void ReversePrint(Node *head) { if(head == NULL) { return; } if(head->next == NULL) { printf("%d\n", head->data); } else { ReversePrint(head->next); printf("%d\n", head->data); } }
/** * built-in commands: exit, in, out, bg, fg, jobs, kill * returns 1 if a built-in command is executed, * 0 otherwise */ int checkBuiltInCommands() { if (strcmp("history", commandArgv[0]) == 0) { ReversePrint(); } if (strcmp("alias", commandArgv[0]) == 0) { return 0; } if(strcmp("which", commandArgv[0]) == 0) { if (commandArgv[1] == NULL) { printf("R-Shell: Missing Parameters\n"); } else { printwhich(); } return 1; } if(strcmp("where", commandArgv[0]) == 0) { if (commandArgv[1] == NULL) { printf("R-Shell: Missing Parameters\n"); } else { printwhere(); } return 1; } if(strcmp("setenv", commandArgv[0]) == 0) { envset(); return 1; } if(strcmp("printenv", commandArgv[0]) == 0) { envprint(); return 1; } if (strcmp("pid", commandArgv[0]) == 0) { printpid(); return 1; } if (strcmp("pwd", commandArgv[0]) == 0) { printpwd(); return 1; } if (strcmp("prompt", commandArgv[0]) == 0) { promptCmd(); return 1; } if (strcmp("exit", commandArgv[0]) == 0) { exit(EXIT_SUCCESS); } if (strcmp("cd", commandArgv[0]) == 0) { changeDirectory(); return 1; } if (strcmp("kill", commandArgv[0]) == 0) { if (commandArgv[1] == NULL) return 0; killJob(atoi(commandArgv[1])); return 1; } if (strcmp("ls", commandArgv[0]) == 0) { return 0; } if (strcmp("cd", commandArgv[0]) == 0) { return 0; } return 0; }