HDU杭电OJ经典100题2000-2099_Java版详细题解(持续更
新)
今年寒假打算⽤Java把杭电2000-2099全部AC(现在持续更新),如下是题⽬链接,之后是我的题解,全部做完后我会把所有AC的题解打包上传的
题号题名题号题名
20002001
20022003
20042005
20062007
20082009
20102011
20122013
20142015
20162017
20182019
20202021
20222023
20242025
20262027
20282029
20302031
20322033
20342035
20362037
20382039
20402041
20422043
20442045
20462047
20482049
20502051
20522053
20542055
20562057
20582059
20602061
20622063 20642065 20662067 20682069 20702071 20722073 20742075 20762077 20782079 20802081 20822083 20842085 20862087 20882089 20902091 20922093 20942095 20962097 20982099如下是2000-2099的题解代码,去掉包并把类名改为Main就可以提交温馨提⽰:使⽤左边的⽬录查你所需要查看的题⽬代码更快哦^-^
⽬录
P2000.ASCII码排序
public class P2000 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
String str = in.next();
int a = str.charAt(0);
int b = str.charAt(1);
int c = str.charAt(2);
int temp;
if(b>a) {
temp = a;
a = b;
b = temp;
}
if(c>a) {
temp = a;
a = c;
c = temp;
}
if(c>b) {
temp = b;
b = c;
c = temp;
}
System.out.println((char)c+" "+(char)b+" "+(char)a);
}
}
}
P2001.计算两点间的距离
package hdu经典100题;
DecimalFormat;
import java.util.Scanner;
public class P2001 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
double x1 = in.nextDouble();
double y1 = in.nextDouble();
double x2 = in.nextDouble();
double y2 = in.nextDouble();
DecimalFormat decimalFormat = new DecimalFormat(".00");
System.out.println(decimalFormat.format(Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)))); }
}
}
P2002.计算球体积
public class P2002 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
double r = in.nextDouble();
System.out.printf("%.3f\n",4.0/3.0*r*r*r*3.1415927);
}
}
}
P2003.求绝对值
package hdu经典100题;
DecimalFormat;
import java.util.Scanner;
public class P2003 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
double num = in.nextDouble();
DecimalFormat decimalFormat = new DecimalFormat(".00"); System.out.println(decimalFormat.format(Math.abs(num)));
}
}
}
P2004.成绩转换
public class P2004 {
public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); while (in.hasNext()) {
int grade = in.nextInt();
if(grade<0 || grade>100) {
System.out.println("Score is error!"); }else {
switch (grade / 10) {
case 10:
System.out.println("A");
break;
case 9:
System.out.println("A");
break;
case 8:
System.out.println("B");
break;
case 7:
System.out.println("C");
break;
case 6:
System.out.println("D");
break;
default:
System.out.println("E");
java valueofbreak;
}
}
}
}
}
P2005.第⼏天?
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论