简单混合运算计算器

2023-11-19

实现一个能够进行简单混合运算的计算器(要求对混合运算的表达式进行先乘除后加减运算)。其实现的效果如下图所示:
在这里插入图片描述
小练习。GUI窗体。
面向对象思路。
代码:

Expression类

package 计算器;
import java.util.LinkedList;

public class Expression extends LinkedList<NumSign>
{
    @Override
    public String toString() {
        String str="";
        for(NumSign numSign:this)
        {
            str=str+numSign.getStrNum()+numSign.getSign();
        }
        return str;
    }
    
    public double calculate()
    {
        calMulAndDiv();
        calAddAndSub();
        return this.get(0).getNum();
    }
    
    private void calMulAndDiv()
    {
        for(int i=0;i<this.size();i++)
        {
            System.out.println(this.toString());
            if(this.size()==1) return;
            if(this.get(i).getSign()=='*')
            {
                double temp=this.get(i).getNum()*this.get(i+1).getNum();
                this.get(i+1).setNum(temp);
                this.remove(i);
                i=-1;
                continue;
            }
            if(this.get(i).getSign()=='/')
            {
                double temp=this.get(i).getNum()/this.get(i+1).getNum();
                this.get(i+1).setNum(temp);
                this.remove(i);
                i=-1;
                continue;
            }
        }
    }
    
    private void calAddAndSub()
    {
        for(int i=0;i<this.size();i++)
        {
            System.out.println(this.toString());
            if(this.size()==1) return;
            if(this.get(i).getSign()=='+')
            {
                double temp=this.get(i).getNum()+this.get(i+1).getNum();
                this.get(i+1).setNum(temp);
                this.remove(i);
                i=-1;
                continue;
            }
            if(this.get(i).getSign()=='-')
            {
                double temp=this.get(i).getNum()-this.get(i+1).getNum();
                this.get(i+1).setNum(temp);
                this.remove(i);
                i=-1;
                continue;
            }
        }
        
    }
    
}

NumSign类

package 计算器;

public class NumSign {
    
    private String strNum;
    private char sign;

    public NumSign() {
    }

    public NumSign(String strNum, char sign) {
        this.strNum = strNum;
        this.sign = sign;
    }

    public String getStrNum() {
        return strNum;
    }

    public void setStrNum(String strNum) {
        this.strNum = strNum;
    }

    public char getSign() {
        return sign;
    }

    public void setSign(char sign) {
        this.sign = sign;
    }

   public double getNum()
   {
       return Double.parseDouble(strNum);
   }
   
   public void setNum(double num)
   {
       this.strNum=String.valueOf(num);
   }
    
    
    
}

Main类

package 计算器;

public class Main {

    
    public static void main(String[] args) {
        // TODO code application logic here
        计算器JFrame jframe=new 计算器JFrame();
        jframe.setVisible(true);
    }
    
}

JFrame类

package 计算器;


public class 计算器JFrame extends javax.swing.JFrame {

    
     Expression expression;
    public 计算器JFrame() {
        initComponents();
        expression=new Expression();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jButton20 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("2");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("3");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("4");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("5");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("6");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setText("7");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setText("8");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setText("9");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setText("0");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton11.setText(".");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton12.setText("=");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton13.setText("+");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jButton14.setText("-");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        jButton15.setText("*");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });

        jButton16.setText("/");
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });

        jButton17.setText("(");

        jButton18.setText(")");

        jButton19.setText("C");
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });

        jButton20.setText("Back");
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jTextField2)
                    .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jButton10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton11))
                            .addComponent(jButton8)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addGap(18, 18, 18)
                                        .addComponent(jButton5)))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jButton17)
                                    .addGap(18, 18, 18)
                                    .addComponent(jButton18))))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(22, 22, 22)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jButton3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jButton12)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jButton9)
                                            .addComponent(jButton19))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jButton20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jButton16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(24, 24, 24)
                                .addComponent(jButton6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton17)
                    .addComponent(jButton18)
                    .addComponent(jButton19)
                    .addComponent(jButton20))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton7)
                    .addComponent(jButton8)
                    .addComponent(jButton9)
                    .addComponent(jButton16))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(jButton5)
                    .addComponent(jButton15)
                    .addComponent(jButton6))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton13)
                    .addComponent(jButton12)
                    .addComponent(jButton11)
                    .addComponent(jButton10))
                .addGap(8, 8, 8))
        );

        pack();
    }// </editor-fold>                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
         this.jTextField1.setText(this.jTextField1.getText()+"1");
    }                                        

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"4");
    }                                        

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    }                                           

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"2");
    }                                        

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"3");
    }                                        

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"5");
    }                                        

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"6");
    }                                        

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"7");
    }                                        

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"8");
    }                                        

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"9");
    }                                        

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+"0");
    }                                         

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        this.jTextField1.setText(this.jTextField1.getText()+".");
    }                                         

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        this.jTextField2.setText("");
        expression.add(new NumSign(this.jTextField1.getText(), '='));
        String temp=this.expression.toString();
        double result=this.expression.calculate();
        this.jTextField2.setText(temp+result+"");
        this.jTextField1.setText("");
        this.expression.clear();
    }                                         

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
         expression.add(new NumSign(this.jTextField1.getText(), '+'));
        this.jTextField1.setText("");
        this.jTextField2.setText(this.expression.toString());
    }                                         

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
         expression.add(new NumSign(this.jTextField1.getText(), '-'));
        this.jTextField1.setText("");
        this.jTextField2.setText(this.expression.toString());
    }                                         

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
         expression.add(new NumSign(this.jTextField1.getText(), '*'));
        this.jTextField1.setText("");
        this.jTextField2.setText(this.expression.toString());
    }                                         

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
         expression.add(new NumSign(this.jTextField1.getText(), '/'));
        this.jTextField1.setText("");
        this.jTextField2.setText(this.expression.toString());
    }                                         

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
         if(this.jTextField1.getText().length()>0)
        this.jTextField1.setText(this.jTextField1.getText().substring(0, this.jTextField1.getText().length()-1));

    }                                         

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
         this.jTextField1.setText("");
        this.jTextField2.setText("");
        this.expression.clear();
    }                                         

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(计算器JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(计算器JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(计算器JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(计算器JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new 计算器JFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration                   
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

简单混合运算计算器 的相关文章

随机推荐

  • 天池数据竞赛docker提交操作学习

    天池数据竞赛docker提交操作学习 由于最近天池的比赛都要求使用docker来提交结果 所以在此记录一下docker提交到天池的整个流程 目前正在做的 全球人工智能技术创新大赛 热身赛二 比赛链接 https tianchi aliyun
  • 高效计算基础与线性分类器

    七月算法5月深度学习班课程笔记 No 2 1 深度学习与应用 1 图像上的应用 可以根据图片 识别图片的内容 描述图像 模仿人的创造性生成画作 相册自动归类等 2 NLP上的应用 用RNN学习某作家的文笔风格进行写作 学习代码写作等 下图为
  • 使用 gperftools 分析程序cpu性能

    一 gperftools 简介 gperftools 是 google 开源的一组套件 提供了高性能的 支持多线程的 malloc 实现 以及一组优秀的性能分析工具 二 安装 gperftools 2 1 下载源码 从 gperftools
  • DockerCompose的安装以及使用

    docker compose的安装以及使用 docker compose的定义 docker compose是docker容器的单机编排工具 它是一个可以管理多容器的工具 比如可以解决多容器之间的依赖关系 比如启动nginx前端服务的时候会
  • redis使用Jackson2JsonRedisSerializer序列化问题

    一 spring boot 集成Redis方法 依赖
  • /proc/modules分析

    参考 redhat linux deployment guide 5 2 21 proc modules This file displays a list of all modules loaded into the kernel Its
  • Qt5实现与单片机ATS89S51通信

    Qt实现与单片机直接的通信上位机 单片机代码 测试环境 项目目标 实现效果 关键通信类 QSerialport 总结 这是我大二下学期的单片机课设做的一个小项目 实现上位机与下位机之间的通信 测试环境 开发环境 Qt5 96 Mingw32
  • Acwing 890. 能被整除的数

    注 S 表示集合S中的元素个数 对于 S1 U S2 U S3 U U Sn 中的任意一个元素x 证明在等式右侧只被计算一次 上述证明中假设x属于k个集合 推出x会被计算的次数 注 Si是指1 n中i的倍数的个数 使用容斥原理的时间复杂度是
  • 3年c/c++开发总结(二):书籍[1]

    对3年来学习中书籍的整理 评价 主要为c c 方面 分数为个人意见 虽然大家都知道 但还是强调下 免得口水 分1 5 5为最高 格式 英文名 中文名 作者 出版社 个人评价 评分 无译者说明是因为建议看原版 p s 国产图书要努力 因看过的
  • (Ext基础篇) 表单与输入控件

    FormPanel和BasicForm详解 我们制作一个Ext form FormPanel 然后在里面设置field 顾名思议 FormPanel是Ext Panel的一个子类 可以对其执行各种Panel操作 实际上 表单的功能是在Ext
  • vue滚动插件:vue-seamless-scroll

    地址 使用 vue seamless scroll 使用方法 1 下包 yarn add vue seamless scroll 2 局部导入 import vueSeamlessScroll from vue seamless scrol
  • 搜索指定站点和指定文档类型

    对于像我这个不生产代码 只是代码搬运工的程序员来说 搜索引擎是必不可少的 遇到问题 搜索一下 基本都能找到答案 但有时 搜索出来的答案千篇一律 而且垃圾网站一波波 这时就要指定搜索某些 网站 如csdn 1 指定站点 在搜索框里面输入 关键
  • HTTP状态码总结

    为了更好地了解各个状态码代表的意思 做了一个总结 在实际的工作中 主要涉及到的还是200 404 500等 1 HTTP状态码分5大类 状态码 类别 100 199 信息性状态码 200 299 成功状态码 300 399 重定向状态码 4
  • 如何在 wxPython 中创建多个工具栏

    在GUI编程领域 wxPython已经成为一个功能强大且通用的库 使开发人员能够轻松制作令人惊叹的图形用户界面 在众多基本组件中 工具栏在为用户提供对各种功能的快速访问方面发挥着至关重要的作用 在本教程中 我们将深入探讨使用 wxPytho
  • LCD笔记(4)分析内核自带的LCD驱动程序

    1 驱动程序框架 Linux驱动程序 驱动程序框架 硬件编程 在前面已经基于QEMU编写了LCD驱动程序 对LCD驱动程序的框架已经分析清楚 核心就是 分配fb info 设置fb info 注册fb info 硬件相关的设置 1 1 入口
  • 使用AS自带工具转换Java文件为.kt问题总结

    android studio Java项目转kotlin问题总结 起因 崩溃问题 部分类Java 和kotlin api存在差异导致编译时报错 起因 忙里偷闲想学一下kotlin 于是在看了一些kotlin基础以后 把项目拉了个分支 想将J
  • pytorch下import numpy失败_深度学习之Pytorch基础教程!

    关注后 星标 Datawhale 每日干货 每月组队学习 不错过 Datawhale干货 作者 李祖贤 Datawhale高校群成员 深圳大学 随着深度学习的发展 深度学习框架开始大量的出现 尤其是近两年 Google Facebook M
  • lscpu命令详解

    基础命令学习目录首页 一 lscpu输出 使用lscpu查看的结果如下图 这里会显示很多信息 如下 使用lscpu p会详细的numa信息 如下 root localhost lscpu p The following is the par
  • 【Mongodb教程 第五课 】MongoDB 删除集合

    drop 方法 MongoDB 的 db collection drop 是用来从数据库中删除一个集合 语法 drop 命令的基本语法如下 db COLLECTION NAME drop 示例 首先 检查可用的集合在数据库 mydb gt
  • 简单混合运算计算器

    实现一个能够进行简单混合运算的计算器 要求对混合运算的表达式进行先乘除后加减运算 其实现的效果如下图所示 小练习 GUI窗体 面向对象思路 代码 Expression类 package 计算器 import java util Linked