陌上花开缓缓归


私信TA

用户名:uq_56682071146

访问量:628

签 名:

等  级
排  名 3584
经  验 1856
参赛次数 0
文章发表 17
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:

①导入

②输入数字、字符、字符串

③比较

④输出

注意事项:

①字符的输入格式: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 人评分

  评论区

  • «
  • »