48天笔试训练错题——day16

文章讨论了数据库服务器的数据可靠性,指出UDP的不可靠性,并介绍了排它锁的概念。同时,给出了一个使用JavaScanner的编程题,涉及扑克牌大小的比较和错误处理。
摘要由CSDN通过智能技术生成

目录

选择题

1.

2.

3.

4.

编程题

1.扑克牌大小


选择题

1.

数据库服务器一定要保证数据的可靠性,而 UDP 是不可靠的。

2.

3.

排它锁:只能获取排它锁的事务自己操作,其他事务不能读也不能写。

4.

alter 就是用来操作表属性的。

编程题

1.扑克牌大小

题目给了提示,按提示写即可。

代码实现:

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            // 将两组牌分开
            String[] cards = str.split("-");
            String[] card1 = cards[0].split(" ");
            String[] card2 = cards[1].split(" ");
            String order = "34567891JQKA2";
            // 先判断对王
            if (cards[0].equals("joker JOKER") || cards[1].equals("joker JOKER")) {
                System.out.println("joker JOKER");
            } else if (card1.length == card2.length) {
                // 比较第一张牌大小即可。
                if (order.indexOf(card1[0].substring(0,1)) 
                        > order.indexOf(card2[0].substring(0, 1))) {
                    System.out.println(cards[0]);
                } else {
                    System.out.println(cards[1]);
                }
            } else if (card1.length == 4) {
                // 如果是炸弹
                System.out.println(cards[0]);
            } else if (card2.length == 4) {
                System.out.println(cards[1]);
            } else {
                System.out.println("ERROR");
            }

        }
    }
}

  • 14
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值