牛客网 编程初学者入门训练 BC34 进制A+B Java

题目来源:牛客网 编程初学者入门训练 BC34 进制A+B
在这里插入图片描述

import java.util.Scanner;
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        String str1 = sc.next();
        String str2 = sc.next();
        int a = Integer.parseInt(str1.replaceAll("^0[x|X]",""),16);
        int b = Integer.parseInt(str2.replaceAll("^0",""),8);
        long sum = (long)a + (long)b;
        System.out.println(sum);
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为您提供一些简单的代码示例来实现打地鼠小游戏。 HTML 部分: ```html <div class="game-container"> <div class="score">得分:<span id="score">0</span></div> <div class="hole hole1"></div> <div class="hole hole2"></div> <div class="hole hole3"></div> <div class="hole hole4"></div> <div class="hole hole5"></div> <div class="hole hole6"></div> </div> ``` CSS 部分: ```css .game-container { width: 600px; height: 400px; margin: 0 auto; position: relative; background-color: #8bc34a; border-radius: 10px; overflow: hidden; } .hole { width: 100px; height: 100px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background-image: url('https://i.imgur.com/m8I4Xfa.png'); background-size: cover; border-radius: 50%; cursor: pointer; transition: all 0.3s ease-in-out; } .hole1 { top: 10%; left: 10%; } .hole2 { top: 10%; left: 50%; } .hole3 { top: 10%; right: 10%; } .hole4 { bottom: 10%; left: 10%; } .hole5 { bottom: 10%; left: 50%; } .hole6 { bottom: 10%; right: 10%; } .hole:hover { transform: scale(1.2); } .score { position: absolute; top: 10px; left: 10px; font-size: 24px; color: #fff; } ``` JavaScript 部分: ```js const holes = document.querySelectorAll('.hole'); const scoreBoard = document.getElementById('score'); let score = 0; function randomTime(min, max) { return Math.round(Math.random() * (max - min) + min); } function randomHole() { const idx = Math.floor(Math.random() * holes.length); const hole = holes[idx]; if (hole === lastHole) { return randomHole(); } lastHole = hole; return hole; } function peep() { const time = randomTime(200, 1000); const hole = randomHole(); hole.classList.add('up'); setTimeout(() => { hole.classList.remove('up'); if (!timeUp) peep(); }, time); } function bonk(e) { if (!e.isTrusted) return; score++; this.classList.remove('up'); scoreBoard.textContent = score; } holes.forEach(hole => hole.addEventListener('click', bonk)); let lastHole; let timeUp = false; let countDown = 30; const timer = setInterval(() => { countDown--; if (countDown < 0) { clearInterval(timer); timeUp = true; alert(`时间到了!你的得分是 ${score} 分!`); } }, 1000); peep(); ``` 以上是一个简单的打地鼠小游戏的实现,希望能对您有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值