2018.5.21(关于Java在oj上的提交以及Java的基本点)

今天是个好日子,521,我终于弄明白了在杭电oj上怎么运行Java程序及Java的几个要点:

 

1.包名删除。

2.Main

3.循环输入。

4.开根和平方。

5.小数点的位数问题。

package E2001;       删除

import java.util.Scanner;

public class Main {         

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
while (input.hasNext()) {
		double x1, y1, x2, y2, y;
		

			x1 = input.nextDouble();
			y1 = input.nextDouble();

			x2 = input.nextDouble();
			y2 = input.nextDouble();
			y = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
			System.out.println(String.format("%.2f", y));

		}

	}
}删除

import java.util.Scanner;

public class Main {         

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
while (input.hasNext()) {
		double x1, y1, x2, y2, y;
		

			x1 = input.nextDouble();
			y1 = input.nextDouble();

			x2 = input.nextDouble();
			y2 = input.nextDouble();
			y = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
			System.out.println(String.format("%.2f", y));

		}

	}
}

java中字符的引入

Scanner scan=new Scanner(System.in);
 String s=scan.next();  //返回一个String 对象
 char c= s.charAt(0) ; //调用String 对象的charAt() 方法,该方法返回char

 


版权声明:本文为qq_42263272原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。