It's really a simple question-given two integers A and B whose absolute value does not exceed 100, you are required to output the result in the format of "A/B=quotient".
Input format:
Input two integers A and B (−100≤A,B≤100) in the first line, separated by spaces.
Output format:
output the result in one line: if the denominator is positive, output "A/B=quotient"; if the denominator is negative, use parentheses to enclose the denominator for output; if the denominator is zero, the output quotient should be Error. The output quotient should keep 2 decimal places.
Input example 1:
-1 2
Output sample 1:
-1/2=-0.50
#include<stdio.h>
int main (void)
{
int A,B;
double C;
scanf("%d %d", &A, &B);
if(0<B){
C=1.0*A/B;
printf("%d/%d=%.2f",A,B,C);
}
else if(B<0){
C=1.0*A/(B);
printf("%d/(%d)=%.2f",A,B,C);
}
else{
printf("%d/0=Error",A);
}
return 0;
}