标签:out bsp imp final 坐标 str util next asn
ACM 2000 输入三个字符后,按各个字符的ASCⅡ码从小打到的顺序输出这三个字符。
import java.util.Scanner;
public class Lengxc {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()) {
String str = scanner.next();
char a = str.charAt(0);
char b = str.charAt(1);
char c = str.charAt(2);
if (a < b) {
if (b < c) {
str = a + " " + b + " " +c;
}else {
if (b > c) {
str = a + " " + c + " " + b;
}else {
str = c + " " + a + " " + b;
}
}
}else {
if (b > c) {
str = c + " " + b + " " + a;
}else {
if (a > c) {
str = b + " " + c + " " + a;
}else {
str = b + " " + a + " " + a;
}
}
}
System.out.println(str);
}
scanner.close();
}
}
ACM 2001 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
import java.util.Scanner;
public class Lengxc {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()) {
double x1 = scanner.nextDouble();
double y1 = scanner.nextDouble();
double x2 = scanner.nextDouble();
double y2 = scanner.nextDouble();
double a = 0;
double b = 0;
a = (x1 - x2) * (x1 - x2) + (y1 - y2) * ( y1 - y2);
b = Math.sqrt(a);
System.out.printf("%.2f",b);
System.out.println();
}
scanner.close();
}
}
ACM 2002 根据输入的半径,计算球的体积
import java.util.Scanner;
public class Lengxc {
public static void main(String[] args) {
final double p = 3.1415928;
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()) {
double r = scanner.nextDouble();
double v = 0.0;
v = p * r * r * r * 4 / 3;
System.out.printf("%.3f",v);
System.out.println();
}
scanner.close();
}
}
标签:out bsp imp final 坐标 str util next asn
原文地址:https://www.cnblogs.com/LXCG/p/9065211.html