From 6a616c7f55dcf791237f92c36c5edd8003845643 Mon Sep 17 00:00:00 2001 From: Nataliia Brown Date: Sat, 10 Feb 2024 01:42:11 -0800 Subject: functions --- In-Class Exercise 10/In-Class Exercise 10/Node.h | 11 ++++++- .../In-Class Exercise 10/PointerExamples.cpp | 28 +++++++++++++++++ .../In-Class Exercise 10/PointerExamples.h | 11 ++++++- .../In-Class Exercise 10/program.cpp | 35 ++++++++++++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) diff --git a/In-Class Exercise 10/In-Class Exercise 10/Node.h b/In-Class Exercise 10/In-Class Exercise 10/Node.h index 6f70f09..a2a3fbd 100644 --- a/In-Class Exercise 10/In-Class Exercise 10/Node.h +++ b/In-Class Exercise 10/In-Class Exercise 10/Node.h @@ -1 +1,10 @@ -#pragma once +#ifndef NODE_H +#define NODE_H + +struct Node { + int data; + Node* _next; + Node* _num; +}; + +#endif \ No newline at end of file diff --git a/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.cpp b/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.cpp index e69de29..ddd1096 100644 --- a/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.cpp +++ b/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.cpp @@ -0,0 +1,28 @@ +// Name: Nataliia Brown +// Date: 2/10/24 +// Class: CST 116 +// Assignment: In-Class Exercise 10 + +#include "PointerExamples.h" +#include "Node.h" + + + +void Swap(Node* first, Node* second) +{ + Node Node3{}; + Node3._num = first._num; + first._num = second._num; + second._num = Node3._num; +} + +void Standardize_101(Node* node) { + + /*n = n % 101;*/ + +} + +void Square(Node* node) { + + /*x *= x;*/ +} \ No newline at end of file diff --git a/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.h b/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.h index 6f70f09..ebba5c4 100644 --- a/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.h +++ b/In-Class Exercise 10/In-Class Exercise 10/PointerExamples.h @@ -1 +1,10 @@ -#pragma once +#ifndef POINTER_EXAMPLES_H +#define POINTER_EXAMPLES_H + +void Swap(Node *first, Node *second); + +void Standardize_101(Node* node); + +void Square(Node* node); + +#endif \ No newline at end of file diff --git a/In-Class Exercise 10/In-Class Exercise 10/program.cpp b/In-Class Exercise 10/In-Class Exercise 10/program.cpp index e69de29..fb00933 100644 --- a/In-Class Exercise 10/In-Class Exercise 10/program.cpp +++ b/In-Class Exercise 10/In-Class Exercise 10/program.cpp @@ -0,0 +1,35 @@ +// Name: Nataliia Brown +// Date: 2/10/24 +// Class: CST 116 +// Assignment: In-Class Exercise 10 + +#include "PointerExamples.h" +#include "Node.h" + +#include + +using std::cout; +using std::cin; +using std::endl; + +int main() { + + Node firstNode{}; + firstNode.data = 438; + + Node secondNode{}; + secondNode.data = 549; + + Node thirdNode{}; + thirdNode.data = 1452; + + Swap(&firstNode, &secondNode); + + cout << "Firts Node is " << firstNode << endl; + + /*Standardize_101(&thirdNode); + + Square(&thirdNode);*/ + + +} \ No newline at end of file -- cgit v1.2.3