#ifndef __UTILS_H__
#define __UTILS_H__

#include <stdio.h>

void inputFrac(int x[]) {
    printf("Input fraction(a/b): ");
    scanf("%d/%d", &x[0], &x[1]);
}

void formatNeg(int x[]) {
    size_t sz = sizeof(int);
    int cnt = 0;
    for (size_t i = 0; i < 2; i++) {
        cnt += x[i] < 0 ? 1 : 0;
        x[i] = x[i] < 0 ? x[i] * -1 : x[i];
    }

    if (cnt == 1)
        x[0] = -1 * x[0];
}

void printFrac(int x[]) {
    if (x[1] == 1) {
        printf("%d", x[0]);
    } else {
        printf("%d/%d", x[0], x[1]);
    }
}

#endif // __UTILS_H__
