From 44e241c4d0109ff80e0840e74888bdb28b17c3f6 Mon Sep 17 00:00:00 2001 From: Mayank Gupta <76836563+cpp-monk@users.noreply.github.com> Date: Fri, 21 Oct 2022 19:07:09 +0530 Subject: [PATCH 1/2] Create 2018955_task01.cpp --- submissions/2018955_task01/2018955_task01.cpp | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 submissions/2018955_task01/2018955_task01.cpp diff --git a/submissions/2018955_task01/2018955_task01.cpp b/submissions/2018955_task01/2018955_task01.cpp new file mode 100644 index 0000000..4650f6c --- /dev/null +++ b/submissions/2018955_task01/2018955_task01.cpp @@ -0,0 +1,60 @@ +#include + +using namespace std; + +int main() +{ + int arr1[1000], arr2[1000], conArr[2000]; + + int n1, n2; + + int i, x; + + cout<<"Enter the Size for First Array : "; + + cin>>n1; + + cout<>arr1[i]; + + conArr[i] = arr1[i]; + } + + x = i; + + cout<>n2; + + cout<>arr2[i]; + + conArr[x] = arr2[i]; + + x++; + } + + cout< Date: Fri, 21 Oct 2022 21:03:23 +0530 Subject: [PATCH 2/2] Create 2018955_task02.cpp --- submissions/2018955_task02/2018955_task02.cpp | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 submissions/2018955_task02/2018955_task02.cpp diff --git a/submissions/2018955_task02/2018955_task02.cpp b/submissions/2018955_task02/2018955_task02.cpp new file mode 100644 index 0000000..0a461ee --- /dev/null +++ b/submissions/2018955_task02/2018955_task02.cpp @@ -0,0 +1,88 @@ +#include + +using namespace std; + +struct node +{ + int data; + + struct node *next; +}; + +void push(struct node **head_ref, int data) +{ + struct node *node; + + node = (struct node*)malloc(sizeof(struct node)); + + node->data = data; + + node->next = (*head_ref); + + (*head_ref) = node; +} + +void reverse(struct node **head_ref) +{ + struct node *temp = NULL; + + struct node *prev = NULL; + + struct node *current = (*head_ref); + + while(current != NULL) + { + temp = current->next; + + current->next = prev; + + prev = current; + + current = temp; + } + + (*head_ref) = prev; + +} + +void printnodes(struct node *head) +{ + while(head != NULL) + { + cout<data<<" "; + + head = head->next; + } +} + + +int main() +{ + struct node *head = NULL; + + push(&head, 45); + + push(&head, 23); + + push(&head, 98); + + push(&head, 12); + + push(&head, 36); + + push(&head, 84); + + cout << "List before reversing" << endl; + + printnodes(head); + + reverse(&head); + + cout << endl; + + cout << "List after reversing"<