Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CTasks4
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
elijah vasquez
CTasks4
Commits
4aa04155
Commit
4aa04155
authored
Jan 15, 2023
by
elijah vasquez
🦍
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SECOND
parent
810c3230
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
ex1.c
ex1.c
+33
-3
ex1.exe
ex1.exe
+0
-0
ex3.c
ex3.c
+2
-0
No files found.
ex1.c
View file @
4aa04155
...
@@ -49,6 +49,7 @@ void AddNodeToStartOfList(node **ptr_to_start, int value)
...
@@ -49,6 +49,7 @@ void AddNodeToStartOfList(node **ptr_to_start, int value)
*ptr_to_start is the contents of the variable head, which is the address of the start of the list.
*ptr_to_start is the contents of the variable head, which is the address of the start of the list.
If we change *ptr_to_start (note only one * here) we are changing the contents of head.
If we change *ptr_to_start (note only one * here) we are changing the contents of head.
We are changing which node is the first node in the list.
We are changing which node is the first node in the list.
*/
*/
node
*
temp
=
NewNode
(
value
);
// Create a new node
node
*
temp
=
NewNode
(
value
);
// Create a new node
...
@@ -90,8 +91,39 @@ void AddNodeToEndOfList(node **ptr_to_start, int value)
...
@@ -90,8 +91,39 @@ void AddNodeToEndOfList(node **ptr_to_start, int value)
}
}
temp
->
next
=
new_node
;
temp
->
next
=
new_node
;
return
;
return
;
}
int
ListLength
(
node
*
start
)
// 1
{
node
*
temp
=
NULL
;
while
(
temp
->
next
!=
NULL
)
{
printf
(
"%d
\n
"
,
temp
->
val
);
temp
=
temp
->
next
;
}
}
void
AddNode
(
node
**
ptr_to_start
,
int
value
)
// 2
{
}
}
/*
int main()
{
AddNodeToStartOfList(&head,5);
AddNodeToEndOfList(&head,7);
AddNodeToEndOfList(&head,2);
AddNodeToEndOfList(&head,1);
AddNodeToEndOfList(&head,4);
AddNodeToEndOfList(&head,3);
return 0;
}
*/
/* Exercise Tasks
/* Exercise Tasks
1. Write a function int ListLength(node *start) which traverses the list, counts the number of nodes and returns that count.
1. Write a function int ListLength(node *start) which traverses the list, counts the number of nodes and returns that count.
...
@@ -124,6 +156,4 @@ AddNodeToEndOfList(&head,1);
...
@@ -124,6 +156,4 @@ AddNodeToEndOfList(&head,1);
AddNodeToEndOfList(&head,4);
AddNodeToEndOfList(&head,4);
AddNodeToEndOfList(&head,3);
AddNodeToEndOfList(&head,3);
*/
*/
ex1.exe
View file @
4aa04155
No preview for this file type
ex3.c
View file @
4aa04155
#include <stdio.h>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment