java小游戏——动漫美女拼图

news2024/10/7 2:18:47

1:继承

1.1 继承概述

首先,我们来说一下,什么是继承:

  • 继承是面向对象三大特征之一(封装,继承和多态)

  • 可以使得子类具有父类的属性和方法,还可以在子类中重新定义,追加属性和方法

也就是说,通过继承,可以把父类中能够被访问到的成员变量和成员方法拿过来直接使用。

了解了什么是继承后,我们在来说一下,继承是如何实现的。

那继承是如何实现的呢?我们一起来看一下继承的格式:

  • 格式:public class 子类名 extends 父类名 { }

  • 范例:public class Zi extends Fu { }

  • Fu:是父类,也被称为基类、超类

  • Zi:是子类,也被称为派生类

在这里,Zi类和Fu类,通过extends就产生了继承关系。这样呢,Zi类就可以使用Fu类中的成员了。

在这里,Fu这个类,被称为是父类,也被称为基类、超类,Zi这个类:是子类,也被称为派生类

了解了继承是如何实现的,下面呢,我们再来举例说明一下,其实我们在前面已经使用过继承的知识了。

看这里,我们使用过GUI中这样的几个组件:

JLabel,JButton,JTextField,JTextArea

并且还使用过它们的一些方法,比如说:public void setBounds(int x, int y, int width, int height),这几个组件我们都使用过这样的一个方法。

大家想一下,如果我们在每个类中都定义这样的同体系的多个类中都使用的方法,有多个这样的组件,我们就要定义多少个这样的方法。

将来如果有新的组件,我们还是需要定义这样的方法,这样设计起来,我们程序的复用性是不是就太差了啊。

而且,这是Java给我们提供的API,Java大师们肯定不会有这么low的设计,

所以,为了提高代码的复用性,这里就采用了继承的思想,让一个类中定义这样的方法,所有继承该类的类就可以使用这个方法了。

来,打开帮助文档,我们一起去看一下:

其他的几个,大家打开文档自己去看,最终能够找到他们共同的父类:Component

看完文档之后,回来总结一下,继承的好处之一是:提高了代码的复用性

1.2 继承的练习

首先,我们来看一下需求:使用继承的方式,改写用户登录界面展示的案例

知道了,要做什么之后,下面呢,我们到IDEA中一边分析,一边实现:

import javax.swing.*;

public class UserLoginFrame extends JFrame {

    public UserLoginFrame() {
        //窗体初始化
        initFrame();

        //绘制窗体
        paintView();

        this.setVisible(true);
    }

    public void paintView() {
        //显示用户名文本
        JLabel usernameLable = new JLabel("用户名");
        usernameLable.setBounds(50, 50, 50, 20);
        this.add(usernameLable);

        //用户名输入框
        JTextField usernameField = new JTextField();
        usernameField.setBounds(150, 50, 180, 20);
        this.add(usernameField);

        //显示密码文本
        JLabel passwordLable = new JLabel("密码");
        passwordLable.setBounds(50, 100, 50, 20);
        this.add(passwordLable);

        //密码输入框
        JPasswordField passwordField = new JPasswordField();
        passwordField.setBounds(150, 100, 180, 20);
        this.add(passwordField);

        //登录按钮
        JButton loginButton = new JButton("登录");
        loginButton.setBounds(50, 200, 280, 20);
        this.add(loginButton);
    }

    public void initFrame() {
        this.setTitle("用户登录");
        this.setSize(400, 300);
        this.setDefaultCloseOperation(3);
        this.setLocationRelativeTo(null);
        this.setAlwaysOnTop(true);
        this.setLayout(null);
    }

}
public class App {
    public static void main(String[] args) {
        UserLoginFrame userLoginFrame = new UserLoginFrame();
    }
}

用继承改进后,代码看起来清晰多了,所以,如果我们做GUI开发的,在做窗体的时候,就会定义类继承自JFrame来使用。

2:动漫美女拼图

2.1 项目演示

这里我们先来演示一下该项目:

来,打开准备好的Java文件,这里有两个类:

一个是动漫拼图窗体的类,一个是测试类。

右键运行测试类,我们看到了这样的一个界面。

大家可以通过按钮来玩这个游戏了。还可以点击求助按钮和重置按钮。

2.2 动漫美女拼图游戏实现

2.2.1 窗体绘制

分析思路:

1:新建一个模块:itheima-picture-puzzle;在模块的src下新建一个包com.itheima

2:在com.itheima这个包下定义类:PictureFrame,继承自JFrame

3:在PictureFrame类中编写无参构造方法,在构造方法中调用两个方法:

第一个方法:initFrame(),用于窗体的基本设置

第二个方法:setVisible(true),用于设置窗体可见

4:在initFrame()方法中编写代码,进行窗体的基本设置

窗体大小

窗体标题

窗体居中

窗体关闭时退出应用程序

窗体位于其他窗口之上

取消窗体默认布局

5:在com.itheima包下定义测试类:App;创建PictureFrame的对象进行测试

代码实现:

public class PictureFrame extends JFrame {
    public PictureFrame() {
        //用于窗体的基本设置
        initFrame();
        //设置窗体可见
        this.setVisible(true);
    }

    //用于窗体的基本设置
    public void initFrame() {
        //窗体大小
        this.setSize(960,565);
        //窗体标题
        this.setTitle("动漫拼图");
        //窗体居中
        this.setLocationRelativeTo(null);
        //窗体关闭时退出应用程序
        this.setDefaultCloseOperation(3);
        //窗体位于其他窗口之上
        this.setAlwaysOnTop(true);
        //取消窗体默认布局
        this.setLayout(null);
    }
}
public class App {
    public static void main(String[] args) {
        PictureFrame pf = new PictureFrame();
    }
}
2.2.2 窗体上组件绘制

分析思路:

1:定义方法,用于窗体上的组件绘制:paintView()

2:按照如下组件绘制

标题图片

面板图片,存储着将来要移动的图片

参照图

上按钮

左按钮

下按钮

右按钮

求助按钮

重置按钮

3:在构造方法中调用paintView()方法

代码实现:

	//窗体上组件的绘制
    public void paintView() {
        //标题图片
        JLabel titleLabel = new JLabel(new ImageIcon("itheima-picture-puzzle\\images\\title.png"));
        titleLabel.setBounds(354,27,232,57);
        this.add(titleLabel);

        //定义一个二维数组,用来存储图片的编号
        int[][] datas = {
                {1,2,3,4},
                {5,6,7,8},
                {9,10,11,12},
                {13,14,15,16}
        };

        //创建面板
        JPanel imagePanel = new JPanel();
        imagePanel.setBounds(150,114,360,360);
        imagePanel.setLayout(null);
        //遍历二维数组,得到图片编号
        for (int i = 0; i < datas.length; i++) {
            for (int j = 0; j < datas[i].length; j++) {
                //创建JLabel对象,加载图片资源
                JLabel imageLabel = new JLabel(new ImageIcon("itheima-picture-puzzle\\images\\"+datas[i][j]+".png"));
                //调整图片的位置
                imageLabel.setBounds(j*90,i*90,90,90);
                imagePanel.add(imageLabel);
            }
        }
        //把面板添加到窗体上
        this.add(imagePanel);

        //动漫参照图
        JLabel canZhaoTuLabel = new JLabel(new ImageIcon("itheima-picture-puzzle\\images\\canzhaotu.png"));
        canZhaoTuLabel.setBounds(574,114,122,121);
        this.add(canZhaoTuLabel);

        //上下左右,求助,重置按钮
        JButton shangButton = new JButton(new ImageIcon("itheima-picture-puzzle\\images\\shang.png"));
        shangButton.setBounds(732,265,57,57);
        this.add(shangButton);

        JButton zuoButton = new JButton(new ImageIcon("itheima-picture-puzzle\\images\\zuo.png"));
        zuoButton.setBounds(650,347,57,57);
        this.add(zuoButton);

        JButton xiaButton = new JButton(new ImageIcon("itheima-picture-puzzle\\images\\xia.png"));
        xiaButton.setBounds(732,347,57,57);
        this.add(xiaButton);

        JButton youButton = new JButton(new ImageIcon("itheima-picture-puzzle\\images\\you.png"));
        youButton.setBounds(813,347,57,57);
        this.add(youButton);

        JButton qiuZhuButton = new JButton(new ImageIcon("itheima-picture-puzzle\\images\\qiuzhu.png"));
        qiuZhuButton.setBounds(626,444,108,45);
        this.add(qiuZhuButton);

        JButton chongZhiButton = new JButton(new ImageIcon("itheima-picture-puzzle\\images\\chongzhi.png"));
        chongZhiButton.setBounds(786,444,108,45);
        this.add(chongZhiButton);

        //展示背景图
        JLabel backgroundLabel = new JLabel(new ImageIcon("itheima-picture-puzzle\\images\\background.png"));
        backgroundLabel.setBounds(0,0,960,530);
        this.add(backgroundLabel);
    }
//构造方法方法中调用绘图方法
	public PictureFrame() {
        //用于窗体的基本设置
        initFrame();
        //窗体上组件的绘制
        paintView();
        //设置窗体可见
        this.setVisible(true);
    }

2.2.3 图片打乱

图片打乱,其实就是二维数组元素打乱。

注意事项:

  • 由于在多个方法中使用同一个数组,故将二维数组的定义放置在成员位置

  • 为了能够进行图片的移动,把16号图片用0号图片替换,当前15个移动到正确位置,显示正确的图片

分析思路:

1:定义方法,用于二维数组元素打乱:initData()

2:创建Random对象

3:遍历存储图片编号的二维数组,得到每一个元素

4:产生两个随机索引,进行二维数组元素交换

	int x = r.nextInt(datas.length);//行索引
    int y = r.nextInt(datas[x].length);//列索引

	//元素交换
    int temp = datas[i][j];
    datas[i][j] = datas[x][y];
    datas[x][y] = temp;

5:在构造方法中调用initData()方法

代码实现:

private int[][] datas = {
        {1, 2, 3, 4},
        {5, 6, 7, 8},
        {9, 10, 11, 12},
        {13, 14, 15, 0}
};
//二维数组元素打乱
public void randomData() {
    Random r = new Random();
    for (int i = 0; i < datas.length; i++) {
        for (int j = 0; j < datas[i].length; j++) {
            int x = r.nextInt(datas.length);
            int y = r.nextInt(datas[i].length);

            int temp = datas[i][j];
            datas[i][j] = datas[x][y];
            datas[x][y] = temp;
        }
    }
}

public PictureFrame() {
    //用于窗体的基本设置
    initFrame();
    //二维数组元素打乱
    randomData();
    //窗体上组件的绘制
    paintView();
    //设置窗体可见
    this.setVisible(true);
}

2.2.4 纪录0号图片的索引

为什么要纪录0号图片索引呢?

  • 由于将来要进行图片的移动,以实现动漫拼图的实现

  • 而移动的操作,得有一个空白的区别,这里我们采用0号图片表示,需要纪录0号图片的位置,也就是在数组中的索引

分析思路:

1:在PictureFrame类中定义两个成员变量用于纪录0号图片的索引

private int x0;

private int y0;

2:在initData()方法中继续编写代码,在打乱后的数组中找到0号图片的位置

遍历二维数组,得到每一个元素

如果元素为0,则纪录该元素的索引,并结束循环。

代码实现:

//定义两个int类型的变量,用于纪录0号图片的位置
private int x0;
private int y0;
//二维数组元素打乱
public void randomData() {
    Random r = new Random();
    for (int i = 0; i < datas.length; i++) {
        for (int j = 0; j < datas[i].length; j++) {
            int x = r.nextInt(datas.length);
            int y = r.nextInt(datas[i].length);

            int temp = datas[i][j];
            datas[i][j] = datas[x][y];
            datas[x][y] = temp;
        }
    }

    //纪录0号图片的位置
    wc:for (int i = 0; i < datas.length; i++) {
        for (int j = 0; j < datas[i].length; j++) {
            if(datas[i][j] == 0) {
                x0 = i;
                y0 = j;
                break wc;
            }
        }
    }
    //System.out.println(x0+","+y0);
}

2.2.5 给按钮注册事件

注意事项:由于在多个方法中使用同一个按钮,故将按钮的定义放置在成员位置

分析思路:

1:定义方法,用于给按钮添加事件:addButtonEvent()

2:在addButtonEvent()方法中给每一个按钮添加事件,并给出输出语句提示

3:在构造方法中调用addButtonEvent()方法

代码实现:

//给按钮添加事件
public void addButtonEvent() {
    shangButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("上");
        }
    });
    zuoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("左");
        }
    });
    xiaButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("下");
        }
    });
    youButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("右");
        }
    });
    qiuzhuButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("求助");
        }
    });
    chongzhiButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("重置");
        }
    });
}
//无参构造方法
public PictureFrame() {
    //用于窗体的基本设置
    initFrame();
    //二维数组元素打乱
    randomData();
    //窗体上组件的绘制
    paintView();
    //给按钮添加事件
    addButtonEvent();
    //设置窗体可见
    this.setVisible(true);
}

2.2.6 移动业务实现

移动原理:图片的移动,其实就是做元素的交换,也就是二维数组的元素改变了,然后进行图片重绘就可以了

2.2.6.1 上移业务实现

分析思路:

1:移动规则:竖的是x,横的是y

空白图片,和下方元素(x0+1),进行交换

2:把空白图片和下方图片的位置交换

datasx0 = datasx0 + 1;

datasx0 + 1 = 0;

x0 = x0 + 1;

3:编写重绘方法:rePaintView()

先移除,再重新绘制

4:调用重绘方法

5:边界问题处理:当x0=3,不能进行上移动

代码实现:

shangButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        //边界处理
        if (x0 == 3) {
            return;
        }
        //位置交换
        datas[x0][y0] = datas[x0 + 1][y0];
        datas[x0 + 1][y0] = 0;
        x0 = x0 + 1;
        //重绘方法调用
        rePaintView();
    }
});

//移动的图形重新绘制
public void rePaintView() {
    //移除所有
    imagePanel.removeAll();

    //遍历二维数组,得到每一个图片编号
    for (int i = 0; i < datas.length; i++) {
        for (int j = 0; j < datas[i].length; j++) {
            //在遍历的过程中,创建 JLabel 对象,加载图片资源
            JLabel imageLabel = new JLabel(new ImageIcon("itheima-picture-puzzle\\images\\" + datas[i][j] + ".png"));
            //调整图片资源的摆放位置
            imageLabel.setBounds(j * 90, i * 90, 90, 90);
            imagePanel.add(imageLabel);
        }
    }

    //重新绘制窗体
    imagePanel.repaint();
}

2.2.6.2 其他移动业务实现

分析思路:

1:左移动

边界:y0=3

移动代码:

        datas[x0][y0] = datas[x0][y0 + 1];
        
        datas[x0][y0 + 1] = 0;
        
        y0 = y0 + 1;

2:下移动

边界:x0=0

移动代码:

     datas[x0][y0] = datas[x0 - 1][y0];
        
        datas[x0 - 1][y0] = 0;
        
        x0 = x0 - 1;

3:右移动

边界:y0=0

移动代码:

        datas[x0][y0] = datas[x0][y0 - 1];
        
        datas[x0][y0 - 1] = 0;
        
        y0 = y0 - 1;

代码实现:

zuoButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        if (y0 == 3) {
            return;
        }
        datas[x0][y0] = datas[x0][y0 + 1];
        datas[x0][y0 + 1] = 0;
        y0 = y0 + 1;
        rePaintView();
    }
});
xiaButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        if (x0 == 0) {
            return;
        }
        datas[x0][y0] = datas[x0 - 1][y0];
        datas[x0 - 1][y0] = 0;
        x0 = x0 - 1;
        rePaintView();
    }
});
youButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        if (y0 == 0) {
            return;
        }
        datas[x0][y0] = datas[x0][y0 - 1];
        datas[x0][y0 - 1] = 0;
        y0 = y0 - 1;
        rePaintView();
    }
});

2.2.7 求助业务实现

注意事项:

  • 数组元素应该是1-16,而不是0-15了

  • 按钮也不能在点击了

分析思路:

1:定义移动成功的方法:success()

2:在success()方法内部进行如下操作:

修改datas数组的元素为正确的元素值

按钮设置为不可用

3:在重置操作中调用两个方法:

第一个方法:success()

第二个方法:rePaintView()

代码实现:

//移动成功的操作
public void success() {
    datas = new int[][]{
            {1, 2, 3, 4},
            {5, 6, 7, 8},
            {9, 10, 11, 12},
            {13, 14, 15, 16}
    };
    shangButton.setEnabled(false);
    zuoButton.setEnabled(false);
    xiaButton.setEnabled(false);
    youButton.setEnabled(false);
}
qiuzhuButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        success();
        rePaintView();
    }
});

2.2.8 移动业务的问题

问题分析:每次移动之后,都要判断是否移动成功,如果成功了,需要调用成功的方法。

而判断移动是否成功,我们来写方法实现。

分析思路:

1:定义一个方法,用于比较两个数组元素是否相同

2:每次移动完毕,调用该方法:

如果返回值为true,则调用success()方法

代码实现:

//定义移动成功后的数组
private int[][] winDatas = {
    {1, 2, 3, 4},
    {5, 6, 7, 8},
    {9, 10, 11, 12},
    {13, 14, 15, 0}
};
//判断移动是否成功
public boolean isSuccess() {
    for (int i = 0; i < datas.length; i++) {
        for (int j = 0; j < datas[i].length; j++) {
            if (datas[i][j] != winDatas[i][j]) {
                return false;
            }
        }
    }
    return true;
}

shangButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        //边界处理
        if (x0 == 3) {
            return;
        }

        //位置交换
        datas[x0][y0] = datas[x0 + 1][y0];
        datas[x0 + 1][y0] = 0;
        x0 = x0 + 1;

        //判断移动是否成功
        if(isSuccess()) {
            success();
        }

        //调用重绘的方法
        rePaintView();
    }
});
zuoButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        //边界处理
        if (y0 == 3) {
            return;
        }

        //位置交换
        datas[x0][y0] = datas[x0][y0 + 1];
        datas[x0][y0 + 1] = 0;
        y0 = y0 + 1;

        //判断移动是否成功
        if(isSuccess()) {
            success();
        }

        //调用重绘的方法
        rePaintView();
    }
});
xiaButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        //边界处理
        if (x0 == 0) {
            return;
        }

        //位置交换
        datas[x0][y0] = datas[x0 - 1][y0];
        datas[x0 - 1][y0] = 0;
        x0 = x0 - 1;

        //判断移动是否成功
        if(isSuccess()) {
            success();
        }

        //调用重绘的方法
        rePaintView();

    }
});
youButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        //边界处理
        if (y0 == 0) {
            return;
        }

        //位置交换
        datas[x0][y0] = datas[x0][y0 - 1];
        datas[x0][y0 - 1] = 0;
        y0 = y0 - 1;

        //判断移动是否成功
        if(isSuccess()) {
            success();
        }

        //调用重绘的方法
        rePaintView();
    }
});
2.2.9 重置业务实现

分析思路:

1:当重置的时候,需要修改数组为1,2...15,0

2:打乱数组元素

3:重绘面板图

4:设置按钮可用

代码实现:

chongzhiButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        datas = new int[][]{
                {1, 2, 3, 4},
                {5, 6, 7, 8},
                {9, 10, 11, 12},
                {13, 14, 15, 0}
        };
        initData();
        rePaintView();
        shangButton.setEnabled(true);
        zuoButton.setEnabled(true);
        xiaButton.setEnabled(true);
        youButton.setEnabled(true);
    }
});

讲解完毕后,大家赶快动手练习一下吧。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1385409.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

生日视频模板-试试这样制作

视频制作已经成为表达情感、记录生活的重要方式。尤其在生日这样的特殊日子&#xff0c;一份个性化的视频祝福不仅能让人感到温馨&#xff0c;还能成为长久珍藏的回忆。那么&#xff0c;如何快速制作出精美的生日模版视频呢&#xff1f;下面就给大家介绍几种可以制作生日模版的…

论文阅读:Attention is all you need

【最近课堂上Transformer之前的DL基础知识储备差不多了&#xff0c;但学校里一般讲到Transformer课程也接近了尾声&#xff1b;之前参与的一些科研打杂训练了我阅读论文的能力和阅读源码的能力&#xff0c;也让我有能力有兴趣对最最源头的论文一探究竟&#xff1b;我最近也想按…

300块成本从零开始搭建自己的家庭版NAS还可以自动备份,懂点代码有手就行!

前言 300块成本从零开始搭建自己的家庭版NAS&#xff0c;还可以手机上文件照片音乐自动备份&#xff0c;完全实现了自己的网盘效果&#xff0c;可以设置用户权限分配&#xff0c;目录上传、断点续传、并行上传、拖拽文件上传等日常操作。 为什么要搭建NAS&#xff1f; 现在的手…

【数据库】间隙锁Gap Lock

什么是间隙锁 间隙锁&#xff08;Gap Lock&#xff09;&#xff1a;间隙锁是&#xff08;RR级别下&#xff09;一个在索引记录之间的间隙上的锁&#xff0c;可以是两个索引记录之间&#xff0c;也可能是第一个索引记录之前或最后一个索引之后的空间。间隙锁&#xff08;Gap Lo…

失踪人员信息发布与管理系统:计算机毕设课题的研究与实践 springboot+java+vue+mysql

✍✍计算机编程指导师 ⭐⭐个人介绍&#xff1a;自己非常喜欢研究技术问题&#xff01;专业做Java、Python、微信小程序、安卓、大数据、爬虫、Golang、大屏等实战项目。 ⛽⛽实战项目&#xff1a;有源码或者技术上的问题欢迎在评论区一起讨论交流&#xff01; ⚡⚡ Java实战 |…

Cesium 模型压平

最近整理了下手上的代码&#xff0c;以下是对模型压平的说明。 原理是使用了customShader来重新设置了模型的着色器&#xff0c;通过修改模型顶点的坐标来实现了压平。 废话不多说&#xff0c;下面上代码&#xff1a; /*** class* description 3dtiles模型压平*/ class Flat…

docker-ce 安装与国内源配置 | Ubuntu 20.04

博客原文 文章目录 让apt可以支持HTTPS将官方Docker库的GPG公钥添加到系统中将Docker库添加到APT里更新包列表为了确保修改生效&#xff0c;让新的安装从Docker库里获取&#xff0c;而不是从Ubuntu自己的库里获取&#xff0c;执行&#xff1a;安装 docker-ce配置 docker 阿里源…

Java多线程并发篇----第十四篇

系列文章目录 文章目录 系列文章目录前言一、ReadWriteLock 读写锁二、共享锁和独占锁三、重量级锁(Mutex Lock)四、轻量级锁前言 前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站,这篇文章男女通用,看懂了就去分享给…

【图解数据结构】深入剖析时间复杂度与空间复杂度的奥秘

&#x1f308;个人主页&#xff1a;聆风吟 &#x1f525;系列专栏&#xff1a;图解数据结构、算法模板 &#x1f516;少年有梦不应止于心动&#xff0c;更要付诸行动。 文章目录 一. ⛳️算法的定义二. ⛳️算法的特性2.1 &#x1f514;输入输出2.2 &#x1f514;输入输出2.3 &…

Multimodal Prototypical Networks for Few-shot Learning

tcGAN is provided with an embedding ϕ T \phi_T ϕT​() of the textual description 辅助信息 作者未提供代码

大模型中的显卡优化与分布式训练策略

目录 前言1 大模型训练优化的目标1.1 简单性1.2. 高效性1.3 廉价性 2 显存的组成与利用2.1 参数存储2.2 梯度计算与存储2.3 中间计算结果2.4 优化器信息 3 优化方法3.1 数据并行3.2 模型并行3.3 零冗余优化器&#xff08;Zero Redundancy Optimizer&#xff09;3.4 Pipeline并行…

前端数据魔法:解析数据透视功能实现

前言 在信息爆炸的时代&#xff0c;数据扮演着关键的角色。从庞大的数据中提取有用的信息并进行有效地分析&#xff0c;是一项充满挑战的任务。为了应对这个挑战&#xff0c;数据透视表这一工具应运而生。它通过重新排列和组合数据&#xff0c;使得原始数据更易于理解和分析。…

解决鸿蒙APP的内存泄漏

解决鸿蒙&#xff08;HarmonyOS&#xff09;应用的内存泄漏问题需要采用一系列的策略和技术。与解决Android内存泄漏类似&#xff0c;以下是一些建议&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合作。 1…

增强FAQ搜索引擎:发挥Elasticsearch中KNN的威力

英文原文地址&#xff1a;https://medium.com/nerd-for-tech/enhancing-faq-search-engines-harnessing-the-power-of-knn-in-elasticsearch-76076f670580 增强FAQ搜索引擎&#xff1a;发挥Elasticsearch中KNN的威力 2023 年 10 月 21 日 在一个快速准确的信息检索至关重要的…

收银系统源码,连锁店收银系统源码

智慧新零售系统是一套线下线上一体化的收银系统。致力于给零售门店提供『多样化线下收银』、『ERP进销存』、『o2o小程序商城』、『精细化会员管理』、『丰富营销插件』等一体化行业解决方案&#xff01; 一、多样化线下收银 1.聚合收款码 ①适用商户&#xff1a;小微门店&am…

在 .NET 中使用可以漫游的 Web 凭据

Windows 凭据管理器是一个内置在 Windows 操作系统中的功能&#xff0c;为用户提供一种安全的方式来存储和管理凭据。本文主要介绍如何在 .NET 中使用可以漫游的 Web 凭据&#xff0c;以及使用中的基本事项。 1. 引言 在前面的文章《试用 Windows Terminal 中的 Terminal Chat…

SwiftUI CoreData Picker

开发多账本功能 CoreData 与 Picker 的使用 上代码&#xff1a; // // TestZhangBenPicker.swift // pandabill // // Created by 朱洪苇 on 2024/1/14. //import SwiftUIstruct TestZhangBenPicker: View {FetchRequest(sortDescriptors: [SortDescriptor(\.cc_at)],anima…

人工智能与六西格玛设计:一场颠覆性的融合之旅

随着科技的飞速发展&#xff0c;人工智能&#xff08;AI&#xff09;和六西格玛设计&#xff08;Six Sigma&#xff09;已成为当今企业追求卓越的关键工具。当这两大领域相遇&#xff0c;它们将引发一场创新与变革的狂潮。本文将探讨AI与六西格玛设计结合的潜力&#xff0c;以及…

MySQL 查看表结构简单命令

一、简单描述表结构&#xff0c;字段类型 desc tabl_name; # 表名 显示表结构&#xff0c;字段类型&#xff0c;主键&#xff0c;是否为空等属性。 二、查询表中列的注释信息 select * from information_schema.columns where table_schema db #表所在数据库 and table_n…

易基因:表观遗传学和表观转录组修饰在植物金属和准金属暴露中的作用 | 抗逆综述

大家好&#xff0c;这里是专注表观组学十余年&#xff0c;领跑多组学科研服务的易基因。 非必需金属&#xff08;non-essential metal&#xff09;和准金属&#xff08;metalloid&#xff0c;也称类金属&#xff09;对土壤的污染是全球许多地区面临的严重问题。这些非必需金属…