分别输入abcde五个整型数,让他们依次与18进行加减乘除模运算,然后让五个结果与10进行比较,有一个真结果就是真,把这个功能写到一个式子里面
可以函数
public static int max(int a,int b,int c,int d,int e){
int max=a;
if(max<b){
max=b;
}
if(max<c){
max=c;
}
if(max<d){
max=d;
}
if(max<e){
max=e;
}
return(max);
}
public static void main(String[] args) {
int a,b,c,d,e,m=0;
Scanner s=new Scanner(System.in);
a=s.nextInt();
b=s.nextInt();
c=s.nextInt();
d=s.nextInt();
e=s.nextInt();
boolean res=true;
m=max(a+18,b-18,c*18,d/18,e%18);
res=m>10;
System.out.println(res);
}
也可以简单粗暴
public static void main(String[] args) {
int a, b, c, d, e, m = 0;
Scanner s = new Scanner(System.in);
a = s.nextInt();
b = s.nextInt();
c = s.nextInt();
d = s.nextInt();
e = s.nextInt();
System.out.println(a + 18 > 10 || b - 18 > 10 || c * 18 > 10 || d / 18 > 10 || e % 18 > 10);
}