JAVA GUI 植物大戰僵尸

公眾號:編程驛站

沒有做太多封裝。難免有冗余。源碼全部放出,有興趣者可以再改之。

1. pea 類

package com.hm;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;/***/
public class Pea {BufferedImage image;int x;int y;Rectangle rectangle;//寬度//高度int size;public Pea(int x, int y) throws IOException {this.image= ImageIO.read(new File("images/background/pea.png"));this.x=x;this.y=y;this.size=25;this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);}public void draw(Graphics g){g.drawImage(this.image,this.x,this.y,this.size,this.size,null);this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);this.x+=50;}
}

2. PeaShooter

package com.hm;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;public class PeaShooter {BufferedImage image;int x;int y;Rectangle rectangle;//預加載所有豌豆射手圖片BufferedImage[] images=new BufferedImage[13];int index=0;int live=40;public PeaShooter(int x,int y) throws IOException {this.x=x;this.y=y;for (int i = 0; i <13 ; i++) {String code=i<9?"0"+(i+1):(i+1)+"";images[i]= ImageIO.read(new File("images/peashooter/PeaShooter_"+code+".png"));}this.image=images[index];this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());}public void draw(Graphics graphics){index=++index%13;//0 12this.image=images[index];this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());// graphics.drawRect(this.x,this.y,this.image.getWidth(),this.image.getHeight());graphics.drawImage(this.image,this.x,this.y,this.image.getWidth(),this.image.getHeight(),null);}
}

3. Sun

package com.hm;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;/*** 自然光(隨機)* 向日葵生產(與向日葵)*/
public class Sun {BufferedImage image;int x;int y;Rectangle rectangle;//寬度//高度int size;//是否被鼠標點擊int isMeetMouse=0;//x長度int xlength;//yint ylength;public Sun(int x,int y) throws IOException {this.image= ImageIO.read(new File("images/background/Sun.png"));this.x=x;this.y=y;this.size=60;this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);}public void draw(Graphics g){this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);g.drawImage(this.image,this.x,this.y,this.size,this.size,null);}
}

4. SunFlower

package com.hm;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;public class SunFlower {BufferedImage image;int x;int y;Rectangle rectangle;//預加載所有豌豆射手圖片BufferedImage[] images=new BufferedImage[18];int index=0;//生命值int live=30;public SunFlower(int x, int y) throws IOException {this.x=x;this.y=y;for (int i = 0; i <18 ; i++) {String code=i<9?"0"+(i+1):(i+1)+"";images[i]= ImageIO.read(new File("images/SunFlower/SunFlower_"+code+".png"));}this.image=images[index];this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());}public void draw(Graphics graphics){index=++index%18;//0 12this.image=images[index];this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());//graphics.drawRect(this.x,this.y,this.image.getWidth(),this.image.getHeight());graphics.drawImage(this.image,this.x,this.y,this.image.getWidth(),this.image.getHeight(),null);}
}

5. Zombie

package com.hm;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;public class Zombie {BufferedImage image;int x;int y;Rectangle rectangle;//預加載所有豌豆射手圖片BufferedImage[] walkImages = new BufferedImage[31];BufferedImage[] dieImages = new BufferedImage[10];BufferedImage[] headImages = new BufferedImage[10];//吃播圖片BufferedImage[] eatImages = new BufferedImage[21];//索引號int index = 0;int index_ = 0;int indexEat = 0;//走 1 正在走,0停int run = 1;//生命值int live = 4;public Zombie(int x, int y) throws IOException {this.x = x;this.y = y;for (int i = 0; i < 31; i++) {String code = i < 9 ? "0" + (i + 1) : (i + 1) + "";walkImages[i] = ImageIO.read(new File("images/Zombie/Walk/Walk_" + code + ".png"));}for (int i = 0; i < 10; i++) {String code = i < 9 ? "0" + (i + 1) : (i + 1) + "";dieImages[i] = ImageIO.read(new File("images/Zombie/Die/Die_" + code + ".png"));}for (int i = 0; i < 10; i++) {String code = i < 9 ? "00" + (i + 1) : "0" + (i + 1);headImages[i] = ImageIO.read(new File("images/Zombie/Head/Head_" + code + ".png"));}for (int i = 0; i < 21; i++) {String code = i < 9 ? "0" + (i + 1) : (i + 1) + "";eatImages[i] = ImageIO.read(new File("images/Zombie/Eat/Eat_" + code + ".png"));}this.image = walkImages[index];this.rectangle = new Rectangle(this.x, this.y, this.image.getWidth(), this.image.getHeight());}public void draw(Graphics graphics) {if (this.live > 0) {if (this.run == 1) {index = ++index % 31;//0 30this.image = walkImages[index];this.x -= 5;} else {indexEat = ++indexEat % 21;//0 30this.image = eatImages[indexEat];}} else {index_ = ++index_ % 10;//0 30this.image = dieImages[index_];graphics.drawImage(this.headImages[index_], this.x, this.y, this.headImages[index_].getWidth() - 20, this.headImages[index_].getHeight() - 20, null);}this.rectangle = new Rectangle(this.x, this.y, this.image.getWidth() - 20, this.image.getHeight() - 20);//graphics.drawRect(this.x, this.y, this.image.getWidth()-20, this.image.getHeight()-20);graphics.drawImage(this.image, this.x, this.y, this.image.getWidth() - 20, this.image.getHeight() - 20, null);}
}

6. MainFrm

package com.hm;import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Random;/*** AudionClip sound_choose=Applet.newAdudioClip(sound1.toURL());*/
public class MainFrm extends JFrame {//創建BackGround backGround = new BackGround();//太陽光數量卡片Card sunCountCard;//生產向日葵Card sunFlowerCard;//生產碗豆射手Card peaShooterCard;//陽光(自然光):定時隨時創建Sun sun = null;//隨機Random random = new Random();//定時器Timer timer;//陽光從天上移動目標Yint sunTargetY;//鼠標是否點擊到陽光int sunMeetMouse = 0;//陽光離收集面板x方向長度int xlength;//陽光離收集面板y方向長度int ylength;Image offScreenImage = null;//陽光數量int sunCount = 500;//射手是否已經創建int isCreatePeaShooter = 0;//射手PeaShooter peaShooter;//是否種下來int isPeaFloor = 0;//子彈Pea pea;//容器(子彈)LinkedList<Pea> peas = new LinkedList();//容器(豌豆射手)LinkedList<PeaShooter> peaShooters = new LinkedList();//僵尸Zombie zombie;LinkedList<Zombie> zombies = new LinkedList();//一個箱子變量向日葵SunFlower sunFlower;//保存所有向日葵LinkedList<SunFlower> sunFlowers = new LinkedList<>();//是否已經存下int isSunFlowerDown = 0;//向日葵生產陽光Sun sun_;//容器,保存所有向口葵生產出來的陽光LinkedList<Sun> suns = new LinkedList<>();//開始BufferedImage startImage;int total = 50; //總量int total_ = total;int count = 0;//房子int isFail=0;//成功BufferedImage okImage;//失敗BufferedImage noImage;public MainFrm() throws IOException {startImage = ImageIO.read(new File("images/background/start.jpg"));okImage = ImageIO.read(new File("images/background/trophy.png"));noImage = ImageIO.read(new File("images/background/ZombiesWon.png"));BufferedImage image = ImageIO.read(new File("images/card/plants/SunBank.png"));sunCountCard = new Card(image, 200, 40);sunCountCard.rectangle.setBounds(200, -10, 100, 100);image = ImageIO.read(new File("images/card/plants/SunFlower.png"));sunFlowerCard = new Card(image, 265, 40);image = ImageIO.read(new File("images/card/plants/Peashooter.png"));peaShooterCard = new Card(image, 325, 40);this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);//大小this.setSize(1400, 600);//位置this.setLocation(200, 100);//標題this.setTitle("植物大戰僵尸");//this.setResizable(false);//使用定時器timer = new Timer(100, new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {if (sun == null) {try {//創建陽光(自然光)createSun();//定制一個目標點sunTargetY = random.nextInt(300) + 100;} catch (IOException ioException) {ioException.printStackTrace();}} else {//陽光存在讓其移動sunMove();}//創建子彈if (pea == null && peaShooters.size() != 0) {try {//根據武器數量調整生產子彈的頻率int wuCount = peaShooters.size();int num_ = 5;if (wuCount > 5) {num_ = 1;}int randNum = random.nextInt(num_);//0~9if (randNum == 0) { //1/5int num = random.nextInt(peaShooters.size());////從武器庫中根據隨機數字得到武器PeaShooter ps = peaShooters.get(num);if (ps != peaShooter) {//隨機出來的武器不是正在移動的武器pea = new Pea(ps.x + 80, ps.y);//添加容器中peas.addLast(pea);pea = null;}}} catch (Exception ioException) {ioException.printStackTrace();}}//向日葵生產陽光if (sun_ == null && sunFlowers.size() != 0) {try {//頻率int wuCount = sunFlowers.size();int num_ = 20;if (wuCount > 10) {num_ = 10;}int randNum = random.nextInt(num_);//0~9if (randNum == 0) { //1/5int num = random.nextInt(sunFlowers.size());////根據隨機數字得到太陽花SunFlower ps = sunFlowers.get(num);if (ps != sunFlower) {sun_ = new Sun(ps.x, ps.y);//添加容器中suns.addLast(sun_);sun_ = null;}}} catch (Exception ioException) {ioException.printStackTrace();}}if (suns.size() != 0) {sunMove_();}//生產僵尸if (zombie == null && count != total_) {int jsNum = random.nextInt(30);if (jsNum == 10) {int y = random.nextInt(350) + 50;//0~9try {zombie = new Zombie(1300, y);count++;zombies.addLast(zombie);zombie = null;} catch (IOException ioException) {ioException.printStackTrace();}}}peaIsMeetZombie();isZombieMeetSunFlowerOrPeaShooter();repaint();}});timer.start();//窗體接收鼠標點擊this.addMouseMotionListener(new MouseMotionAdapter() {@Overridepublic void mouseMoved(MouseEvent e) {if (peaShooter != null) {if (isPeaFloor == 0) {//沒有種下時與鼠標一起移動peaShooter.x = e.getX();peaShooter.y = e.getY();} else {//種下之后恢復變量到初始狀態peaShooter = null;isPeaFloor = 0;}}if (sunFlower != null) {if (isSunFlowerDown == 0) {//沒有種下時與鼠標一起移動sunFlower.x = e.getX();sunFlower.y = e.getY();} else {//種下之后恢復變量到初始狀態sunFlower = null;isSunFlowerDown = 0;}}}});this.addMouseListener(new MouseAdapter() {@Overridepublic void mouseClicked(MouseEvent e) {//鼠標坐標是否和陽光的坐標疊if (sunMeetMouse == 0 && sun != null) {if (sun.rectangle.contains(e.getX(), e.getY())) {sunMeetMouse = 1;xlength = Math.abs(sun.x - 200);ylength = Math.abs(sun.y - 40);}}//檢查鼠標是不是點擊到了向日葵所生產的陽光if (suns.size() != 0) {for (Sun s : suns) {if (s.rectangle.contains(e.getX(), e.getY())) {//有陽光碰到鼠標s.isMeetMouse = 1;s.xlength = Math.abs(s.x - 200);s.ylength = Math.abs(s.y - 40);break;}}}//種植武器if (peaShooter == null) {if (peaShooterCard.rectangle.contains(e.getX(), e.getY())) {if (sunCount >= 100) {try {//創建一個 武器peaShooter = new PeaShooter(e.getX(), e.getY());//放置武器容器peaShooters.addLast(peaShooter);sunCount -= 100;} catch (IOException ioException) {ioException.printStackTrace();}}}} else {isPeaFloor = 1;}//種植太陽花if (sunFlower == null) {if (sunFlowerCard.rectangle.contains(e.getX(), e.getY())) {if (sunCount >= 50) {try {//創建一個 武器sunFlower = new SunFlower(e.getX(), e.getY());//放置武器容器sunFlowers.addLast(sunFlower);sunCount -= 50;} catch (IOException ioException) {ioException.printStackTrace();}}}} else {isSunFlowerDown = 1;}}});}@Overridepublic void paint(Graphics g) {super.paint(g);if (offScreenImage == null) {offScreenImage = this.createImage(1400, 600);}g.drawImage(offScreenImage, 0, 0, null);Graphics gOffScreen = offScreenImage.getGraphics();//2DGraphics2D graphics2D = (Graphics2D) gOffScreen;gOffScreen.fillRect(0, 0, 1400, 600);gOffScreen.setColor(Color.white);this.backGround.draw(gOffScreen);this.sunCountCard.draw(gOffScreen);this.sunFlowerCard.draw(gOffScreen);this.peaShooterCard.draw(gOffScreen);//繪制分值gOffScreen.setFont(new Font("黑體", Font.BOLD, 20));gOffScreen.setColor(Color.red);gOffScreen.drawString(this.sunCount + "", 215, 110);//繪制所有武器if (this.peaShooters != null) {for (int i = 0; i < peaShooters.size(); i++) {peaShooters.get(i).draw(gOffScreen);}}//繪制所有太陽花if (this.sunFlowers != null) {for (int i = 0; i < sunFlowers.size(); i++) {sunFlowers.get(i).draw(gOffScreen);}}//繪制陽光if (this.sun != null)this.sun.draw(gOffScreen);//繪制所有僵尸if (zombies.size() != 0) {for (int i = 0; i < zombies.size(); i++) {zombies.get(i).draw(gOffScreen);}}//繪制豌豆子彈if (peas != null) {for (int i = 0; i < peas.size(); i++) {if (peas.get(i).x > 1400) {peas.remove(peas.get(i));continue;}peas.get(i).draw(gOffScreen);}}//繪制豌豆子彈if (suns != null) {for (int i = 0; i < suns.size(); i++) {if (suns.get(i).x > 1400) {suns.remove(suns.get(i));continue;}suns.get(i).draw(gOffScreen);}}gOffScreen.setFont(new Font("黑體", Font.BOLD, 30));//繪制數量gOffScreen.drawString("當前的僵尸數量:" + this.total, 400, 100);//全部消滅之后if (this.total == 0) {gOffScreen.drawImage(this.okImage, 600, 200, this.okImage.getWidth(), this.okImage.getHeight(), null);}if (this.isFail==1){gOffScreen.drawImage(this.noImage, 400, 100, this.noImage.getWidth(), this.noImage.getHeight(), null);}}/*** 生產自然光*/public void createSun() throws IOException {//指定位置int y = -100;int x = this.random.nextInt(500) + 260;//260 760sun = new Sun(x, y);}/*** 移動陽光*/public void sunMove() {//確定目標坐標if (sunMeetMouse == 0) {if (this.sun.y < this.sunTargetY)this.sun.y += 25;} else if (sunMeetMouse == 1) {if (this.sunCountCard.rectangle.contains(this.sun.x + 50, this.sun.y + 50)) {this.sunCount += 25;//重置陽光數據this.sun = null;this.sunMeetMouse = 0;} else {//設定y速度int yspeed = 15;//求解X軸int xspeed = (yspeed * xlength) / ylength;this.sun.x -= xspeed;this.sun.y -= yspeed;}}if (this.sun != null)this.sun.rectangle.setBounds(this.sun.x, this.sun.y, this.sun.size, this.sun.size);}public void sunMove_() {//確定目標坐標for (int i = 0; i < suns.size(); i++) {Sun s = suns.get(i);if (s == null)continue;if (s.isMeetMouse == 1) {if (this.sunCountCard.rectangle.intersects(s.rectangle)) {this.sunCount += 25;//重置陽光數據s.isMeetMouse = 0;suns.remove(s);} else {//設定y速度int yspeed = 15;//求解X軸int xspeed = (yspeed * s.xlength) / s.ylength;s.x -= xspeed;s.y -= yspeed;}}}}//添加方法:檢查子彈是不是碰到了僵尸public void peaIsMeetZombie() {//for (int i = 0; i < zombies.size(); i++) {//僵尸Zombie zb = zombies.get(i);if (zb == null)continue;//回收if (zb.index_ >= 9) {zombies.remove(zb);this.total--;if (this.total == 0) {//timer.stop();//repaint();// return;}break;}//檢查是否已經全部死亡for (int j = 0; j < peas.size(); j++) {Pea p = peas.get(j);if (p == null)continue;if (zb.rectangle.intersects(p.rectangle)) {if (zb.live > 0)zb.live -= 1;peas.remove(p);}}}}/*** 僵尸碰到植物*/public void isZombieMeetSunFlowerOrPeaShooter() {for (int i = 0; i < zombies.size(); i++) {Zombie zb = zombies.get(i);if (zb == null) continue;if (zb.x<150){this.isFail=1;}if (zb.x<130){timer.stop();return;}//太陽花for (int j = 0; j < sunFlowers.size(); j++) {SunFlower sf = sunFlowers.get(j);if (sf == null) continue;if (zb.rectangle.contains(sf.rectangle) && sunFlower == null) {if (sf.live > 0) {zb.run = 0;sf.live--;} else {zb.run = 1;sunFlowers.remove(sf);}break;}}for (int j = 0; j < peaShooters.size(); j++) {PeaShooter ps = peaShooters.get(j);if (ps == null) continue;if (zb.rectangle.contains(ps.rectangle) && peaShooter == null) {if (ps.live > 0) {zb.run = 0;ps.live--;} else {zb.run = 1;peaShooters.remove(ps);}break;}}}}
}

7. Card

package com.hm;import java.awt.*;
import java.awt.image.BufferedImage;public class Card {//圖片BufferedImage image;int x;int y;//范圍Rectangle rectangle;public Card(BufferedImage image,int x,int y){this.image=image;this.x=x;this.y=y;this.rectangle=new Rectangle(this.x,this.y,60,75);}/*** 繪制*/public void draw(Graphics graphics){graphics.drawImage(this.image,this.x,this.y,60,75,null);}
}

8.BackGround

package com.hm;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;/*** 背景有關代碼*/
public class BackGround {//圖片BufferedImage image;//位置 xint x;//yint y;public BackGround() throws IOException {//加載圖片this.image= ImageIO.read(new File("images/background/background1.jpg"));this.x=0;this.y=0;}/*** 繪制*/public  void draw(Graphics graphics){graphics.drawImage(this.image,this.x,this.y,1400,600,null);}
}公眾號里回復   植物大戰僵尸  獲取源代碼和素材!```

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/13366.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/13366.shtml
英文地址,請注明出處:http://en.pswp.cn/web/13366.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

物業水電抄表系統的全面解析

1.系統概述 物業水電抄表系統是現代物業管理中的重要組成部分&#xff0c;它通過自動化的方式&#xff0c;實時監控和記錄居民或企業的水電使用情況&#xff0c;極大地提高了工作效率&#xff0c;降低了人工抄表的錯誤率。該系統通常包括數據采集、數據傳輸、數據分析和數據展…

鏈表OJ題(移除鏈表元素,反轉鏈表,分割鏈表,環形鏈表(是否成環問題),鏈表中間節點(快慢指針講解),環形鏈表(找入環節點))“題目來源力扣附帶題目鏈接”

目錄 1.移除鏈表元素 2.反轉鏈表 2.1三指針法 2.2頭插法 3.分割鏈表 4.鏈表的中間節點&#xff08;快慢指針&#xff09; 4.1快慢指針 4.2求鏈表的中間節點 5.環形鏈表 5.1環形鏈表是否成環 5.2環形鏈表入環節點 5.3入環節點推論的不完備性說明 1.移除鏈表元素 移除…

Microsoft Threat Modeling Tool 使用(三)

Boundary&#xff08;邊界&#xff09; 本文介紹信任邊界&#xff0c;基于 SDL TM Knowledge Base (Core) 模版&#xff0c;這是一個通用的威脅建模模板&#xff0c;非常適合初學者和大多數威脅建模需求。 這些邊界&#xff08;Boundary&#xff09;在微軟威脅建模工具中用于表…

Java多線程與高并發

1、什么是進程?什么是線程? 進程:進程是程序的基本執行實體;另外一種解釋是進程是一個應用程序(1個進程是一個軟件)。 線程:線程是操作系統能夠進行運算調度的最下單位。它被包含在進程之中,是進程中的實際運作單位;是一個進程中的執行場景/執行單元。 注意:。一個進…

uniapp實現列表拖拽排序+滑動刪除功能

此篇代碼在原插件基礎進行了bug修改與滑動功能的新增 原插件地址 HM-dragSorts.vue組件使用 HM-dragSorts.vue <template><view class""><view class"HM-drag-sort" :style"{height: ListHeightrpx,background-color: listBackground…

魔法方法介紹

【一】什么是魔法方法 在類內部達到指定條件會自動觸發的方法 【二】魔法方法 # 【1】__init__ &#xff1a; 實例化類得到對象的時候會自動觸發 class Student(object):def __init__(self):print(f"實例化類的時候觸發") # 實例化類的時候觸發 ? s Student…

在云服務器上運行StyleGAN3生成偽樣本

首先是傳入數據&#xff0c;這里我們不做贅述。 對于數據格式的裁剪&#xff0c;可以通過以下代碼進行&#xff1a; from glob import glob from PIL import Image import os from tqdm import tqdm from tqdm.std import trangeimg_path glob(r"C:\Users\Administrato…

【Oracle篇】rman物理備份工具的基礎理論概述(第一篇,總共八篇)

??博主介紹??&#xff1a; ?又是一天沒白過&#xff0c;我是奈斯&#xff0c;DBA一名? ???擅長Oracle、MySQL、SQLserver、阿里云AnalyticDB for MySQL(分布式數據倉庫)、Linux&#xff0c;也在擴展大數據方向的知識面??? ??????大佬們都喜歡靜靜的看文章&am…

嵌入式是大坑的說法,是否與學生的信息不對稱有關?

在開始前我有一些資料&#xff0c;是我根據網友給的問題精心整理了一份「嵌入式的資料從專業入門到高級教程」&#xff0c; 點個關注在評論區回復“888”之后私信回復“888”&#xff0c;全部無償共享給大家&#xff01;&#xff01;&#xff01; 目前也算是在搞嵌入式&#…

【深度學習】時空圖卷積網絡(STGCN),預測交通流量

論文地址&#xff1a;https://arxiv.org/abs/1709.04875 Spatio-Temporal Graph Convolutional Networks: A Deep Learning Framework for Traffic Forecasting 文章目錄 一、摘要二、數據集介紹美國洛杉磯交通數據集 METR-LA 介紹美國加利福尼亞交通數據集 PEMS-BAY 介紹美國…

Cocktail for Mac 激活版:一站式系統優化與管理神器

Cocktail for Mac是一款專為Mac用戶打造的系統優化與管理工具&#xff0c;憑借其強大的功能和簡便的操作&#xff0c;贏得了廣大用戶的喜愛。這款軟件集系統清理、修復和優化于一身&#xff0c;能夠幫助用戶輕松解決Mac系統中的各種問題&#xff0c;提高系統性能。 Cocktail fo…

Leetcode-有效的括號(帶圖)

20. 有效的括號 - 力扣&#xff08;LeetCode&#xff09;https://leetcode.cn/problems/valid-parentheses/ 題目 給定一個只包括 (&#xff0c;)&#xff0c;{&#xff0c;}&#xff0c;[&#xff0c;] 的字符串 s &#xff0c;判斷字符串是否有效。 有效字符串需滿足&…

在做題中學習(59):除自身以為數組的乘積

238. 除自身以外數組的乘積 - 力扣&#xff08;LeetCode&#xff09; 解法&#xff1a;前綴積和后綴積 思路&#xff1a;answer中的每一個元素都是除自己以外所有元素的和。那就處理一個前綴積數組和后綴積數組。 而前綴積(f[i])是&#xff1a;[0,i-1]所有元素的乘積 后綴…

如何利用香港多IP服務器實現定制化的網絡服務

如何利用香港多IP服務器實現定制化的網絡服務 在當今數字化快速發展的時代&#xff0c;企業對于網絡服務的需求日益增加&#xff0c;尤其是對于定制化和高度可調整的網絡服務的需求。香港&#xff0c;作為國際金融中心和數據中心的樞紐&#xff0c;提供了優越的網絡基礎設施和…

什么是蜜罐,在當前網絡安全形勢下,蜜罐能提供哪些幫助

在當前的互聯網時代&#xff0c;網絡安全威脅日益嚴峻&#xff0c;攻擊手段層出不窮。為了應對這些威脅&#xff0c;網絡安全專家們不斷探索新的防御手段&#xff0c;在過去的幾年里&#xff0c;一種更加積極主動的網絡安全方法正在興起。蜜罐技術便是這樣一種備受矚目的主動防…

【教學類-55-05】20240516圖層順序挑戰(三格長條紙加黑色邊框、3*3、5張,不重復7186張,9坐標點顏色哈希值去重、保留5色)

背景需求&#xff1a; 前期測試了4*4框格種的8種顏色&#xff0c;隨機抽取7種&#xff0c;隨機排列圖層&#xff0c;去掉相同的圖片、保留7種顏色的圖片&#xff0c;最后獲得5400張樣圖 【教學類-55-04】20240515圖層順序挑戰&#xff08;四格長條紙加黑色邊框、4*4、7張&…

Python程序設計 文件處理(二)

實驗十二 文件處理 第1關&#xff1a;讀取宋詞文件&#xff0c;根據詞人建立多個文件 讀取wjcl/src/step1/宋詞.txt文件&#xff0c; 注意&#xff1a;宋詞文件的標題行的詞牌和作者之間是全角空格&#xff08;" ")可復制該空格 在wjcl/src/step3/cr文件夾下根據每…

【CSND博客紀念】“創作紀念日:從靈感迸發到小有成就——我的CSND博客創作之旅”

&#x1f3a9; 歡迎來到技術探索的奇幻世界&#x1f468;?&#x1f4bb; &#x1f4dc; 個人主頁&#xff1a;一倫明悅-CSDN博客 ?&#x1f3fb; 作者簡介&#xff1a; C軟件開發、Python機器學習愛好者 &#x1f5e3;? 互動與支持&#xff1a;&#x1f4ac;評論 &…

記錄下git的基本操作

初始化git git init git clone 拉取各分支的最新代碼 git fetch 切換分支 git checkout 分支名 提交相關操作 git add . git commit -m “提交備注” 兩個一起 git commit -am “提交備注” 如果需要撤銷操作 git log 查詢日志,提交id git revert git revert HEAD 撤銷前一…

算法分析與設計復習__遞歸方程與分治

總結自&#xff1a;【算法設計與分析】期末考試突擊課_嗶哩嗶哩_bilibili 1.遞歸&#xff0c;遞歸方程 1.1遞歸條件: 1.一個問題的解可以分解為幾個子問題的解&#xff1b; 2.這個問題與分解之后的子問題&#xff0c;除了數據規模不同&#xff0c;求解思路完全一樣; 3.存在…