-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinkedlist.cpp
53 lines (38 loc) · 913 Bytes
/
Linkedlist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<"\n"
#define print(x) cout<<x<<"\n"
// linked list
// creating a struct for singly linked list
struct Node{
int data;
Node *next;
};
Node* getnewnode(){
Node *temp = (Node*)malloc(sizeof(Node));
temp->data = -1;
temp->next = NULL;
return temp;
}
int main(){
return 0;
}
// ############# Extra code to test #############
struct Nodevec{
struct Node arr[100];
int size;
};
Nodevec* create_node_vec(int arr[],int n){
Nodevec* temp = (Nodevec*)malloc(sizeof(Nodevec));
temp->size = 0;
for(int i=0;i<n;i++){
int num = arr[i];
Node* nodeptr = getnewnode();
nodeptr->data = num;
// not linking now the next ptr
temp->arr[temp->size++] = *nodeptr;
}
for(int i=0;i<n-1;i++){
temp->arr[i].next = &(temp->arr[i+1]);
}
}