题目解析
将给定两个数进行除法运算
解题思路
特判b的情况
然后直接输出结果
代码
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int a = sc.nextInt();
int b = sc.nextInt();
if (b == 0)
out.printf("%d/%d=Error", a, b);
else if (b < 0)
out.printf("%d/(%d)=%.2f", a, b, a * 1.0 / b);
else
out.printf("%d/%d=%.2f", a, b, a * 1.0 / b);
out.flush();
out.close();
}
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
}