You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
public class ExcTest {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
// 请在Begin-End间编写代码
|
|
|
|
|
/********** Begin **********/
|
|
|
|
|
// 第一步:接收给定的整数
|
|
|
|
|
Scanner input=new Scanner(System.in);
|
|
|
|
|
int a = input.nextInt();
|
|
|
|
|
int b = input.nextInt();
|
|
|
|
|
int x;
|
|
|
|
|
// 第二步:求给定两个数的商,并捕获除数为0的异常
|
|
|
|
|
try{
|
|
|
|
|
x = a / b;
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
{
|
|
|
|
|
System.out.println("除数不能为0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(b != 0){
|
|
|
|
|
System.out.println(a / b);
|
|
|
|
|
}
|
|
|
|
|
/********** End **********/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|