解题思路:
①导入
②输入数字、字符、字符串
③比较
④输出
注意事项:
①字符的输入格式:next().charAt(0);
②字符串的输入格式:next();
③绝对值的计算:abs(num1-num2);
④字符串的比较:str1.compareTo(str2)
参考代码:
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int a = s.nextInt(); int b = s.nextInt(); char c = s.next().charAt(0); char d = s.next().charAt(0); String e = s.next(); String f = s.next(); if(a>b) { System.out.println(a); } else { System.out.println(b); } System.out.println(Math.abs((int)c-(int)d)); if(e.compareTo(f)>=0) { System.out.println(e); } else { System.out.println(f); } } }
0.0分
0 人评分
C语言训练-阶乘和数* (C++代码)(直接输出样例hhhh)浏览:1170 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:597 |
C语言训练-8除不尽的数 (C语言代码)暴力解法,答案只有一个,直接输出就好了浏览:1037 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:666 |
九宫重排 (C++代码)浏览:1404 |
C语言程序设计教程(第三版)课后习题10.1 (Java代码)浏览:1485 |
简单的a+b (C语言代码)浏览:737 |
大神老白 (C语言代码)浏览:686 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)浏览:2092 |
WU-printf基础练习2 (C++代码)浏览:2040 |