aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
blob: a4716e1af29db503f9da7494bfd8ee069bff0d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>

void printarr(int a[], int n) {
  for (int i = 0; i < n; i++) {
    printf(COLOR_BOLD "%d " COLOR_OFF, a[i]);
  }
}


void swap(int a[], int i, int j) {
  int tmp = a[i];
  a[i] = a[j];
  a[j] = tmp;
}


void clearscreen(void) {
#ifdef _WIN32
    system("cls");
#elif defined(unix) || defined(__unix__) || defined(__unix) ||                 \
    (defined(__APPLE__) && defined(__MACH__))
    system("clear");
#else
#error "OS not supported."
#endif
}