/* * Solution Template for Mixed Fraction * * This file is provided to assist with reading and writing of the input * files for the problem. You may modify this file however you wish, or * you may choose not to use this file at all. */ #include int n; int d; int a; int b; int main(void) { /* Open the input and output files. */ FILE *input_file = fopen("mixin.txt", "r"); FILE *output_file = fopen("mixout.txt", "w"); /* Read the values from the input file. */ fscanf(input_file, "%d%d", &n, &d); /* * TODO: This is where you should compute the answer and store it into * the variables a and b. */ /* Write the answer to the output file. */ if (b != 0) { fprintf(output_file, "%d %d/%d\n", a, b, d); } else { fprintf(output_file, "%d\n", a); } /* Finally, close the input/output files. */ fclose(input_file); fclose(output_file); return 0; }