杭电OJ刷题记录(二):简单操作

2000—2011、2039
import java.util.Scanner;
import java.text.DecimalFormat; //格式化十进制

//用于处理日期和时间的类
import java.util.Calendar;  //抽象类
import java.util.GregorianCalendar; //具体实现,公历

public class Day2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//  2000.ASCII码排序
//  可以直接用ASCII码表示字符
//  ab\ac\bc
//        while (sc.hasNext()) {
//            String s = sc.next();
//            int a = s.charAt(0);
//            int b = s.charAt(1);
//            int c = s.charAt(2);
//            int tmp;
//            if (a > b){
//                tmp = a;
//                a = b;
//                b = tmp;
//            }
//            if (a > c){
//                tmp = c;
//                c = a;
//                a = tmp;
//            }
//            if (b > c){
//                tmp = b;
//                b = c;
//                c = tmp;
//            }
//            System.out.println((char) a+" "+(char) b+" "+(char) c);
//        }

//  2001.计算两点间的距离
//        while (sc.hasNext()) {
//            double x1 = sc.nextDouble(), y1 = sc.nextDouble(),x2 = sc.nextDouble(),y2 = sc.nextDouble();
//            double d= Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
//            DecimalFormat decimalFormat = new DecimalFormat(".00");
//            System.out.println(decimalFormat.format(d));
//        }

//  2002.计算球体积
//        while (sc.hasNext()) {
//            double r = sc.nextDouble();
//            double pi =3.1415927;
//            DecimalFormat decimalFormat = new DecimalFormat(".000");
//            double v = r*r*r*pi*4.0/3.0;
//            System.out.println(decimalFormat.format(v));
//        }

//  2003.求绝对值
//        while (sc.hasNext()) {
//            double n = sc.nextDouble();
//            if(n<0){
//                n = n*(-1.0);
//            }
//            DecimalFormat decimalFormat = new DecimalFormat(".00");
//            System.out.println(decimalFormat.format(n));
//        }

//  2004.成绩转换
//  整除代替双重判断
//        while (sc.hasNext()) {
//            int score = sc.nextInt();
//            if (score <0 || score >100 ) {
//                System.out.println("Score is error!");
//            }
//            else {
//                switch (score /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");
//                        break;
//                }
//            }
//        }

//  2005.第几天?
//        while(sc.hasNext()){
//            String date = sc.next();
//            int year =  Integer.valueOf(date.substring(0,4));
//            int month =  Integer.valueOf(date.substring(5,date.lastIndexOf('/')));
//            int day =  Integer.valueOf(date.substring(date.lastIndexOf('/')+1));
//            Calendar calendar = new GregorianCalendar(year, month-1,day); // Calendar里面月份从0开始算起
//            System.out.println(calendar.get(Calendar.DAY_OF_YEAR));
//        }

//  2006.求奇数的乘积
//        while(sc.hasNext()){
//            int num = sc.nextInt(),result =1;
//            for (int i =0;i<num;i++){
//                int n = sc.nextInt();
//                if (n % 2!=0){
//                    result = result * n;
//                }
//            }
//            System.out.println(result);
//        }

//  2007.平方和与立方和
//        while(sc.hasNext()){
//            int a = sc.nextInt(), b = sc.nextInt();
//            int cube = 0, square = 0;
            相对大小不一定确定
//            if(a > b){
//                int tmp=a;
//                a= b;
//                b =tmp;
//            }
//            for(int i=a;i<=b;i++){
//                if(i%2==0){
//                    square+=i*i;
//                }
//                else{
//                    cube+=i*i*i;
//                }
//            }
//            System.out.println(square+" "+cube);
//        }

//  2008.数值统计
//        while(sc.hasNext()){
//            int num = sc.nextInt();
//            int negative =0, positive =0, zero =0;
//            if(num==0)break;
//            for (int i=0;i<num;i++){
//                double n = sc.nextDouble();
//                if(n>0){
//                    positive+=1;
//                }
//                else if (n<0) {
//                    negative +=1;
//                }
//                else{
//                    zero +=1;
//                }
//            }
//            System.out.println(negative+" "+zero+" "+positive);
//        }

//  2009.求数列的和
//        while (sc.hasNext()){
//            double n = sc.nextDouble();
//            int m = sc.nextInt();
//            double sum = 0;
//            for (int i = 0; i < m; i++) {
//                sum+=n;
//                n = Math.sqrt(n);
//            }
//            DecimalFormat decimal = new DecimalFormat(".00");
//            System.out.println(decimal.format(sum));
//        }

//  2010.水仙花数
//        while (sc.hasNext()) {
//            int m = sc.nextInt(), n = sc.nextInt();
//            int count = 0;
            排序
//            if (m > n) {
//                int tmp = m;
//                m = n;
//                n = tmp;
//            }
//            for (int i = m; i <= n; i++) {
//                int a = i / 100;
//                int b = (i - a * 100) / 10;
//                int c = (i - a * 100 - b * 10);
//                if (i == a * a * a + b * b * b + c * c * c) {
//                    System.out.print(i + " ");
//                    count += 1;
//                }
//            }
//            if (count == 0) {
//                System.out.println("no");
//            }
//        }

//  2011.多项式求和
//        while (sc.hasNext()){
//            int num=sc.nextInt();
//            double sum =0;
//            for(int i=0;i<num;i++){
//                sum = 0;
//                int  n = sc.nextInt();
//                for (int j=1;j<=n;j++){
//                    sum += Math.pow(-1,j+1)/j;
//                }
//                DecimalFormat decimal = new DecimalFormat("0.00");
//                System.out.println(decimal.format(sum));
//            }
//        }

//  2039.三角形
        while (sc.hasNext()){
            int num = sc.nextInt();
            double tmp=0.0;
            for (int i = 0; i < num; i++) {
                double a = sc.nextDouble(), b = sc.nextDouble(), c = sc.nextDouble();
                if(a>b){
                    tmp =a;
                    a=b;
                    b=tmp;
                }
                if(a>c){
                    tmp =a;
                    a=c;
                    c=tmp;
                }
                if(b>c){
                    tmp =b;
                    b=c;
                    c=tmp;
                }
                if(a+b>c){
                    System.out.println("YES");
                }
                else{
                    System.out.println("NO");
                }
            }
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值