This repository contains a C implementation for performing arithmetic operations on multivariate polynomials using a linked list representation. It is designed to solve the Machine Exercise 1 - Polynomial Operations as a course requirement for CS 32 (24.2 WFX_MLNO) - University of the Philippines Diliman, Department of Computer Science.
The program implements five of the following polynomial operations at once:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Long Division (/) (without remainder)
- Modulo Operation (%) (remainder of polynomial division)
It follows a canonical ordering of variables (x, y, z) using lexicographical ordering for polynomial terms.
- Each operation begins with one of the symbols:
+,-,*,/,%. - Each polynomial is represented as:
- First line: Number of non-zero terms.
- Next lines: Each term as four values:
- Three non-negative integers (exponents of x, y, z).
- A nonzero real number (coefficient).
- Multiple terms with the same exponents must be combined.
- Input ends when
#is encountered.
+
2
2 0 0 1
0 2 0 -1
2
1 0 0 1
0 1 0 1
#- Each result starts with
---. - Each term follows the format
exponent_x exponent_y exponent_z coefficient. - Coefficients are printed with four decimal places.
- Terms are sorted in descending order, prioritizing x > y > z.
---
2 0 0 1.0000
1 0 0 1.0000
0 2 0 -1.0000
0 1 0 1.0000- Input is always valid.
- Coefficients fit within the
floatdata type.
- Leonard Ang (2022-01328)
- Justin Chuah (2023-00514)