C-Playground/main.c

46 lines
1.1 KiB
C
Executable File

#include <stdio.h>
#include "lib/temperature.h"
#include "lib/array.h"
#include "lib/base10.h"
// #include "lib/math.h"
void swapInt(int *pX, int *pY) {
int temp = *pX;
*pX = *pY;
*pY = temp;
}
#define ALLOCSIZE 10000
char allocbuff[ALLOCSIZE];
char* allocp = allocbuff;
char* alloc(int n) {
if (allocbuff + ALLOCSIZE - allocp >= n) {
allocp += n;
return allocp - n;
} else
return 0;
}
int main() {
intArray unsortedArray;
int unsortedArrayData[] = { 1, 5, 2, 1, 4, 8, 3, 2, 6, 7 };
unsortedArray.length = sizeof(unsortedArrayData) / sizeof(int);
unsortedArray.data = unsortedArrayData;
intArray sortedArray;
int sortedArrayData[] = { 1, 2, 4, 8, 9, 9, 9 };
sortedArray.length = sizeof(sortedArrayData) / sizeof(int);
sortedArray.data = sortedArrayData;
printf("Unsorted Array : ");
printIntArray(&unsortedArray);
printf("Unsorted Array Sorted?: %d\n", checkIntArraySorted(&unsortedArray));
printf("Sorted Array : ");
printIntArray(&sortedArray);
printf("Sorted Array Sorted?: %d\n", checkIntArraySorted(&sortedArray));
printf("40C == %dF\n", (int) celsiusToFarenheit(40.0));
}