#include "shared.h" #define MAXINP 100000 /* call cordic and maclaurin and the print output */ void work_print(double x) { double csin, msin, rsin; csin = cordic(x); msin = maclaurin(x); printf("%-8f %-8f %-8f %-8f\n", x, csin, msin, sin(x)); } int main(int argc, char *argv[]) { int i; double x; if (argc > 1) { double darr[argc-1]; for (i = 0; i < argc - 1; i++) { darr[i] = atof(argv[i+1]); x = darr[i]; work_print(x); } } else { i = 0; clock_t start, stop; double * darr = malloc(MAXINP*sizeof(double)); start = clock(); while((scanf("%lf", &darr[i])) == 1) { x = darr[i]; work_print(x); i++; } stop = clock(); printf("\nElapsed time = %g Seconds\n", (stop-start)/((float) CLOCKS_PER_SEC)); free(darr); } return 0; }