67 lines
No EOL
1.8 KiB
C
Executable file
67 lines
No EOL
1.8 KiB
C
Executable file
/*----------------------------------------------------------
|
|
* HTBLA-Leonding
|
|
* ---------------------------------------------------------
|
|
* Author: Marc Tismonar
|
|
* ----------------------------------------------------------
|
|
* Description:
|
|
* Encapsulates roman numbers and provides basic mathematical operations.
|
|
* ----------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef ___ROMAN_NUMBER
|
|
#define ___ROMAN_NUMBER
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef struct RomanNumberData* RomanNumber;
|
|
|
|
/**
|
|
* Creates a roman number from the given string.
|
|
* If the given string is not valid or not a valid
|
|
* number, an invalid RomanNumber is provided.
|
|
*
|
|
* @param value The roman number string.
|
|
* @return RomanNumber
|
|
*/
|
|
RomanNumber rn_create(char* value);
|
|
|
|
/**
|
|
* Determines whether or not the RomanNumber is valid.
|
|
*
|
|
* @param number The number to test.
|
|
* @return true if the number is valid, false otherwise.
|
|
*/
|
|
bool rn_is_valid(RomanNumber number);
|
|
|
|
/**
|
|
* Provides the value of the RomanNumber or a value less
|
|
* than zero, if the number is not valid.
|
|
*
|
|
* @param number The number to convert.
|
|
* @return The integral value of the roman number or a value
|
|
* less than 0;
|
|
*/
|
|
int rn_get_value(RomanNumber number);
|
|
|
|
/**
|
|
* Calculates the greatest common divisor of two roman numbers.
|
|
*
|
|
* @param x The first number.
|
|
* @param y The second number.
|
|
* @return The result or an invalid roman number, if at least one
|
|
* of the given values is invalid.
|
|
*/
|
|
RomanNumber rn_gcd(RomanNumber x, RomanNumber y);
|
|
|
|
/**
|
|
* Calculates the greatest common divisor of two integers.
|
|
*
|
|
* @param x The first operand.
|
|
* @param y The second operand
|
|
* @return The result.
|
|
*/
|
|
int int_gcd(int x, int y);
|
|
|
|
#endif |