Search
Write a simple program that:
In the case of zero in the numerator, the program prints just zero. When there is zero in the denominator, the program prints Error and returns 1.
Error
1
Hint: look at the GCD and find an algorithm to compute it.
Some examples of the program behaviour when called as ./main
./main
2 / 4
1 / 2
0
765 / 918
5 / 6
101 / 100
0 / 78
99 / 0
You can find more testing instances here. Files with the suffix .in contain your input with .out your desired output.
.in
.out
When you have your input in a file, e.g. pub00.in containing
pub00.in
$ cat pub00.in | ./main 1 / 2
main.c