COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
main3_3.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "3.h"
Include dependency graph for main3_3.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 5 of file main3_3.c.

5 {
6 int n = 1;
7 ListNode * listArray = (ListNode *)malloc(n * sizeof(ListNode));
8
9 ListNode * listPtr = &listArray[0];
10 ListNode * newNode1 = (ListNode *)malloc(sizeof(ListNode));
11 ListNode * newNode2 = (ListNode *)malloc(sizeof(ListNode));
12 ListNode * newNode3 = (ListNode *)malloc(sizeof(ListNode));
13 ListNode * newNode4 = (ListNode *)malloc(sizeof(ListNode));
14 listPtr->data = 1;
15 listPtr->next = newNode1;
16 newNode1->data = 2;
17 newNode1->next = newNode2;
18 newNode2->data = 1;
19 newNode2->next = newNode3;
20 newNode3->data = 2;
21 newNode3->next = newNode4;
22 newNode4->data = 1;
23 newNode4->next = newNode2;
24
25 double average = findAverageCycleLength(listArray, n);
26
27 printf("%f\n", average);
28
29 free(newNode1);
30 free(newNode2);
31 free(newNode3);
32 free(newNode4);
33 free(listArray);
34}
double findAverageCycleLength(ListNode *arrPtr, int n)
Definition 3.c:4
Definition 3.h:4
int data
Definition 3.h:5
struct listNode * next
Definition 3.h:6

References listNode::data, findAverageCycleLength(), and listNode::next.

Here is the call graph for this function: