201771010109焦旭超《面向对象程序设计(java)》第十六周学习总结

1、实验目的与要求

(1) 掌握线程概念;

(2) 掌握线程创建的两种技术;

(3) 理解和掌握线程的优先级属性及调度方法;

(4) 掌握线程同步的概念及实现技术;

2、实验内容和步骤

实验1:测试程序并进行代码注释。

测试程序1:

l 在elipse IDE中调试运行ThreadTest,结合程序运行结果理解程序;

l 掌握线程概念;

掌握用Thread的扩展类实现线程的方法;

利用Runnable接口改造程序,掌握用Runnable接口创建线程的方法。

class Lefthand extends Thread { public void run(){for(int i=0;i<=5;i++){  System.out.println("You are Students!");try{   sleep(500);   }catch(InterruptedException e){ System.out.println("Lefthand error.");}    } } 
}
class Righthand extends Thread {public void run(){for(int i=0;i<=5;i++){   System.out.println("I am a Teacher!");try{  sleep(300);  }catch(InterruptedException e){ System.out.println("Righthand error.");}}}
}
public class ThreadTest 
{static Lefthand left;static Righthand right;public static void main(String[] args){     left=new Lefthand();right=new Righthand();left.start();right.start();}
}
ThreadTest

利用Runnable接口改造程序,掌握用Runnable接口创建线程的方法

class Lefthand implements Runnable { public void run(){for(int i=0;i<=5;i++){  System.out.println("You are Students!");try{   Thread.sleep(500);//休眠500毫秒
           }catch(InterruptedException e){ System.out.println("Lefthand error.");}    } }}
class Righthand implements Runnable {public void run(){for(int i=0;i<=5;i++){   System.out.println("I am a Teacher!");try{  Thread.sleep(300);//休眠300毫秒
             }catch(InterruptedException e){ System.out.println("Righthand error.");}}}}
public class ThreadTest 
{public static void main(String[] args){   Righthand righthand = new Righthand();//新建一个righthand对象Lefthand lefthand = new Lefthand();//新建一个lefthand对象Thread right = new Thread(righthand);//start方法在Thread类中,新建Thread类
         right.start();Thread left=new Thread(lefthand);left.start();}
}
Runnable接口

测试程序2

l 在Elipse环境下调试教材625页程序14-1、14-2 14-3,结合程序运行结果理解程序;

l 在Elipse环境下调试教材631页程序14-4,结合程序运行结果理解程序;

l 对比两个程序,理解线程的概念和用途;

l 掌握线程创建的两种技术。

package bounce;import java.awt.geom.*;/*** A ball that moves and bounces off the edges of a rectangle* @version 1.33 2007-05-17* @author Cay Horstmann*/
public class Ball
{private static final int XSIZE = 15;private static final int YSIZE = 15;private double x = 0;private double y = 0;private double dx = 1;private double dy = 1;/*** Moves the ball to the next position, reversing direction if it hits one of the edges*/public void move(Rectangle2D bounds){x += dx;y += dy;if (x < bounds.getMinX()){x = bounds.getMinX();dx = -dx;}if (x + XSIZE >= bounds.getMaxX()){x = bounds.getMaxX() - XSIZE;dx = -dx;}if (y < bounds.getMinY()){y = bounds.getMinY();dy = -dy;}if (y + YSIZE >= bounds.getMaxY()){y = bounds.getMaxY() - YSIZE;dy = -dy;}}/*** Gets the shape of the ball at its current position.*/public Ellipse2D getShape(){return new Ellipse2D.Double(x, y, XSIZE, YSIZE);}
}
ball
package bounce;import java.awt.*;
import java.util.*;
import javax.swing.*;/*** The component that draws the balls.* @version 1.34 2012-01-26* @author Cay Horstmann*/
public class BallComponent extends JPanel
{private static final int DEFAULT_WIDTH = 450;private static final int DEFAULT_HEIGHT = 350;private java.util.List<Ball> balls = new ArrayList<>();/*** Add a ball to the component.* @param b the ball to add*/public void add(Ball b){balls.add(b);}public void paintComponent(Graphics g){super.paintComponent(g); // erase backgroundGraphics2D g2 = (Graphics2D) g;for (Ball b : balls){g2.fill(b.getShape());}}public Dimension getPreferredSize() { return new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT); }
}
BallComponent
package bounce;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;/*** Shows an animated bouncing ball.* @version 1.34 2015-06-21* @author Cay Horstmann*/
public class Bounce
{public static void main(String[] args){EventQueue.invokeLater(() -> {JFrame frame = new BounceFrame();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);});}
}/*** The frame with ball component and buttons.*/
class BounceFrame extends JFrame
{private BallComponent comp;public static final int STEPS = 1000;public static final int DELAY = 3;/*** Constructs the frame with the component for showing the bouncing ball and* Start and Close buttons*/public BounceFrame(){setTitle("Bounce");comp = new BallComponent();add(comp, BorderLayout.CENTER);JPanel buttonPanel = new JPanel();addButton(buttonPanel, "Start", event -> addBall());addButton(buttonPanel, "Close", event -> System.exit(0));add(buttonPanel, BorderLayout.SOUTH);pack();}/*** Adds a button to a container.* @param c the container* @param title the button title* @param listener the action listener for the button*/public void addButton(Container c, String title, ActionListener listener){JButton button = new JButton(title);c.add(button);button.addActionListener(listener);}/*** Adds a bouncing ball to the panel and makes it bounce 1,000 times.*/public void addBall(){try{Ball ball = new Ball();comp.add(ball);for (int i = 1; i <= STEPS; i++){ball.move(comp.getBounds());comp.paint(comp.getGraphics());Thread.sleep(DELAY);}}catch (InterruptedException e){}}
}
Bounce

package bounceThread;import java.awt.*;
import java.awt.event.*;import javax.swing.*;/*** Shows animated bouncing balls.* @version 1.34 2015-06-21* @author Cay Horstmann*/
public class BounceThread
{public static void main(String[] args){EventQueue.invokeLater(() -> {JFrame frame = new BounceFrame();frame.setTitle("BounceThread");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);});}
}/*** The frame with panel and buttons.*/
class BounceFrame extends JFrame
{private BallComponent comp;public static final int STEPS = 1000;public static final int DELAY = 5;/*** Constructs the frame with the component for showing the bouncing ball and* Start and Close buttons*/public BounceFrame(){comp = new BallComponent();add(comp, BorderLayout.CENTER);JPanel buttonPanel = new JPanel();addButton(buttonPanel, "Start", event -> addBall());addButton(buttonPanel, "Close", event -> System.exit(0));add(buttonPanel, BorderLayout.SOUTH);pack();}/*** Adds a button to a container.* @param c the container* @param title the button title* @param listener the action listener for the button*/public void addButton(Container c, String title, ActionListener listener){JButton button = new JButton(title);c.add(button);button.addActionListener(listener);}/*** Adds a bouncing ball to the canvas and starts a thread to make it bounce*/public void addBall(){Ball ball = new Ball();comp.add(ball);Runnable r = () -> { try{  for (int i = 1; i <= STEPS; i++){ball.move(comp.getBounds());comp.repaint();Thread.sleep(DELAY);}}catch (InterruptedException e){}};Thread t = new Thread(r);t.start();}
}
BounceThread

测试程序3:分析以下程序运行结果并理解程序。

 

class Race extends Thread {public static void main(String args[]) {Race[] runner=new Race[4];for(int i=0;i<4;i++) runner[i]=new Race( );for(int i=0;i<4;i++) runner[i].start( );runner[1].setPriority(MIN_PRIORITY);runner[3].setPriority(MAX_PRIORITY);}public void run( ) {for(int i=0; i<1000000; i++);System.out.println(getName()+"线程的优先级是"+getPriority()+"已计算完毕!");}
}
Race extends Thread

测试程序4

l 教材642页程序模拟一个有若干账户的银行,随机地生成在这些账户之间转移钱款的交易。每一个账户有一个线程。在每一笔交易中,会从线程所服务的账户中随机转移一定数目的钱款到另一个随机账户。

l 在Elipse环境下调试教材642页程序14-5、14-6,结合程序运行结果理解程序;

package unsynch;/*** This program shows data corruption when multiple threads access a data structure.* @version 1.31 2015-06-21* @author Cay Horstmann*/
public class UnsynchBankTest
{public static final int NACCOUNTS = 100;public static final double INITIAL_BALANCE = 1000;//期初余额public static final double MAX_AMOUNT = 1000;//最大数量public static final int DELAY = 10;//延时public static void main(String[] args){Bank bank = new Bank(NACCOUNTS, INITIAL_BALANCE);for (int i = 0; i < NACCOUNTS; i++){int fromAccount = i;Runnable r = () -> {try{while (true){int toAccount = (int) (bank.size() * Math.random());//生成随机数double amount = MAX_AMOUNT * Math.random();bank.transfer(fromAccount, toAccount, amount);Thread.sleep((int) (DELAY * Math.random()));}}catch (InterruptedException e){}            };Thread t = new Thread(r);t.start();}}
}
UnsynchBankTest
package unsynch;import java.util.*;/*** A bank with a number of bank accounts.* @version 1.30 2004-08-01* @author Cay Horstmann*/
public class Bank
{private final double[] accounts;/*** Constructs the bank.* @param n the number of accounts* @param initialBalance the initial balance for each account*/public Bank(int n, double initialBalance){accounts = new double[n];Arrays.fill(accounts, initialBalance);}/*** Transfers money from one account to another.* @param from the account to transfer from* @param to the account to transfer to* @param amount the amount to transfer*/public void transfer(int from, int to, double amount){if (accounts[from] < amount) return;System.out.print(Thread.currentThread());accounts[from] -= amount;System.out.printf(" %10.2f from %d to %d", amount, from, to);accounts[to] += amount;System.out.printf(" Total Balance: %10.2f%n", getTotalBalance());}/*** Gets the sum of all account balances.* @return the total balance*/public double getTotalBalance(){double sum = 0;for (double a : accounts)sum += a;return sum;}/*** Gets the number of accounts in the bank.* @return the number of accounts*/public int size(){return accounts.length;}
}
Bank

综合编程练习

编程练习1

  1. 设计一个用户信息采集程序,要求如下:

用户信息输入界面如下图所示:

(1) 用户点击提交按钮时,用户输入信息显示控制台界面;

(2) 用户点击重置按钮后,清空用户已输入信息;

(3) 点击窗口关闭,程序退出。

import java.awt.EventQueue;import javax.swing.JFrame;public class Mian {public static void main(String[] args) {EventQueue.invokeLater(() -> {DemoJFrame page = new DemoJFrame();});}
}
Mian
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ButtonModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;public class DemoJFrame extends JFrame {private JPanel jPanel1;private JPanel jPanel2;private JPanel jPanel3;private JPanel jPanel4;private JTextField fieldname;private JComboBox comboBox;private JTextField fieldadress;private ButtonGroup bg;private JRadioButton nan;private JRadioButton nv;private JCheckBox sing;private JCheckBox dance;private JCheckBox draw;public DemoJFrame() {// 设置窗口大小this.setSize(800, 400);// 设置可见性this.setVisible(true);// 设置标题this.setTitle("Student Detail");// 设置关闭操作this.setDefaultCloseOperation(EXIT_ON_CLOSE);// 设置窗口居中WinCenter.center(this);// 创建四个面板对象jPanel1 = new JPanel();setJPanel1(jPanel1);jPanel2 = new JPanel();setJPanel2(jPanel2);jPanel3 = new JPanel();setJPanel3(jPanel3);jPanel4 = new JPanel();setJPanel4(jPanel4);// 设置容器为流式布局FlowLayout flowLayout = new FlowLayout();this.setLayout(flowLayout);// 将四个面板添加到容器中this.add(jPanel1);this.add(jPanel2);this.add(jPanel3);this.add(jPanel4);}/** 设置面板一*/private void setJPanel1(JPanel jPanel) {jPanel.setPreferredSize(new Dimension(700, 45));//设置此组件的首选大小// 给面板的布局设置为网格布局 一行4列jPanel.setLayout(new GridLayout(1, 4));JLabel name = new JLabel("Name:");name.setSize(100, 50);fieldname = new JTextField("");fieldname.setSize(80, 20);JLabel study = new JLabel("Qualification:");comboBox = new JComboBox();comboBox.addItem("Graduate");comboBox.addItem("senior");comboBox.addItem("Undergraduate");jPanel.add(name);jPanel.add(fieldname);jPanel.add(study);jPanel.add(comboBox);}/** 设置面板二*/private void setJPanel2(JPanel jPanel) {jPanel.setPreferredSize(new Dimension(700, 50));// 给面板的布局设置为网格布局 一行4列jPanel.setLayout(new GridLayout(1, 4));JLabel name = new JLabel("Address:");fieldadress = new JTextField();fieldadress.setPreferredSize(new Dimension(150, 50));JLabel study = new JLabel("Hobby:");JPanel selectBox = new JPanel();selectBox.setBorder(BorderFactory.createTitledBorder(""));selectBox.setLayout(new GridLayout(3, 1));sing = new JCheckBox("Singing");dance = new JCheckBox("Dancing");draw = new JCheckBox("Reading");selectBox.add(sing);selectBox.add(dance);selectBox.add(draw);jPanel.add(name);jPanel.add(fieldadress);jPanel.add(study);jPanel.add(selectBox);}/** 设置面板三*/private void setJPanel3(JPanel jPanel) {jPanel.setPreferredSize(new Dimension(700, 150));FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT);jPanel.setLayout(flowLayout);JLabel sex = new JLabel("Sex:");JPanel selectBox = new JPanel();selectBox.setBorder(BorderFactory.createTitledBorder(""));selectBox.setLayout(new GridLayout(2, 1));bg = new ButtonGroup();nan = new JRadioButton("Male");nv = new JRadioButton("Female");bg.add(nan);bg.add(nv);selectBox.add(nan);selectBox.add(nv);jPanel.add(sex);jPanel.add(selectBox);}/** 设置面板四*/private void setJPanel4(JPanel jPanel) {// TODO 自动生成的方法存根jPanel.setPreferredSize(new Dimension(700, 150));FlowLayout flowLayout = new FlowLayout(FlowLayout.CENTER, 50, 10);jPanel.setLayout(flowLayout);jPanel.setLayout(flowLayout);JButton sublite = new JButton("Validate");JButton reset = new JButton("Reset");sublite.addActionListener((e) -> valiData());reset.addActionListener((e) -> Reset());jPanel.add(sublite);jPanel.add(reset);}/** 提交数据*/private void valiData() {// 拿到数据String name = fieldname.getText().toString().trim();String xueli = comboBox.getSelectedItem().toString().trim();String address = fieldadress.getText().toString().trim();System.out.println(name);System.out.println(xueli);String hobbystring="";if (sing.isSelected()) {hobbystring+="Singing   ";}if (dance.isSelected()) {hobbystring+="Dancing   ";}if (draw.isSelected()) {hobbystring+="Reading  ";}System.out.println(address);if (nan.isSelected()) {System.out.println("Male");}if (nv.isSelected()) {System.out.println("Female");}System.out.println(hobbystring);}/** 重置*/private void Reset() {fieldadress.setText(null);fieldname.setText(null);comboBox.setSelectedIndex(0);sing.setSelected(false);dance.setSelected(false);draw.setSelected(false);bg.clearSelection();}
}
DemoJFrame
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;public class WinCenter {public static void center(Window win){Toolkit tkit = Toolkit.getDefaultToolkit();//获取默认工具包Dimension sSize = tkit.getScreenSize();//获取屏幕的大小Dimension wSize = win.getSize();if(wSize.height > sSize.height){wSize.height = sSize.height;}if(wSize.width > sSize.width){wSize.width = sSize.width;}win.setLocation((sSize.width - wSize.width)/ 2, (sSize.height - wSize.height)/ 2);//将组件移到新的位置
    }
}
WinCenter

2.创建两个线程,每个线程按顺序输出5次“你好”,每个“你好”要标明来自哪个线程及其顺序号。

package shiyan2;public class xiancheng 
{static xian1 xian11;static xian2 xian22;        public static void main(String[] args){    xian11=new xian1();xian22=new xian2();               //用start()方法启动线程
       xian11.start();xian22.start();}
}class xian1 extends Thread { public void run(){for(int i=1;i<=5;i++){  System.out.println( i+ "你好"+"     来自线程1");try{   sleep(200);   }catch(InterruptedException e)     //异常{ System.out.println("Lefthand error.");}    } } }class xian2 extends Thread {public void run(){for(int i=1;i<=5;i++){   System.out.println( i+ "你好"+"      来自线程2");try{   sleep(200);   }catch(InterruptedException e)//异常捕获{ System.out.println("Lefthand error.");}    }}}
xiancheng

3. 完善实验十五 GUI综合编程练习程序。

实验总结

  通过本周的学习我了解了线程的概念,并且了解了线程创建的两种技术、线程的优先级属性及调度方法以及终止线程的方法,(1)用Thread类的子类创建线程(2)用Runnable()接口实现线程;理解了线程的优先级属性及调度方法和线程的七种状态。但是这些知识掌握还不牢靠,需要课下多加练习。

转载于:https://www.cnblogs.com/lcjcc/p/10126884.html

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

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

相关文章

Hibernate hql getHibernateTemplate()常用方法汇总

getHibernateTemplate()常用方法 一、find(String queryString); 示例&#xff1a; Java代码 this.getHibernateTemplate().find("from bean.User"); 返回所有User对象 二、find(String queryString , Object value); 示例&#xff1a; Java代码 this.getHib…

阿里巴巴的26款超神Java开源项目!

1.分布式应用服务开发的一站式解决方案 Spring Cloud Alibaba Spring Cloud Alibaba 致力于提供分布式应用服务开发的一站式解决方案。此项目包含开发分布式应用服务的必需组件&#xff0c;方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开发分布式应用服务。 依托…

为DEV C++/CodeBlock配置gdb调试遇到的问题

DEV C和CodeBlock都只是一个IDE&#xff0c;不能编译调试&#xff0c;需要自己配置MINGW和gdb调试 1、MINGW 在这下载mingw-get-setup.exe安装即可。 https://sourceforge.net/projects/mingw/files/MinGW/ 配置MINGW很简单&#xff0c;安装包就好了&#xff0c;可以只安装gcc和…

Java面向对象第二章课后习题

网盘链接&#xff1a; 链接&#xff1a;https://pan.baidu.com/s/12YzJZY3s4XSq5C94HxWqZA 提取码&#xff1a;3w23 一、商场为员工提供了基本工资、物价津贴以及房租津贴。其中&#xff0c;物价津贴为基本工资的40%&#xff0c;房租津贴为基本工资的25%。 要求&#xff1a;从…

Tomcat映射虚拟路径到指定磁盘(eclipse)

用WangEditor富文本编辑&#xff0c;上传图片的时候&#xff0c;本文主要记录一下Tomcat映射虚拟路径到指定磁盘&#xff0c;保存到指定路径中&#xff0c;且能实现页面预览。 在实现之前wangeditor的简单实用请参照博主小道仙的后宫&#xff0c;写的很详细&#xff1a;http://…

JVM内存简析

JAVA的JVM的内存可分为3个区&#xff1a;堆(heap)、栈(stack)和方法区(method) 堆区:1.存储的全部是对象&#xff0c;每个对象都包含一个与之对应的class的信息。(class的目的是得到操作指令)2.jvm只有一个堆区(heap)被所有线程共享&#xff0c;堆中不存放基本类型和对象引用&a…

centos下离线安装mysql

卸载原有冲突的依赖包 rpm -e postfix rpm -e mariadb-libs 按顺序安装 rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm rpm -ivh mysql-com…

记一次es和mq的netty冲突

1.今天在服务里面加了 es 6.4的 依赖包后&#xff0c;在预发布测试时候出现了下列的问题 看了 半天&#xff0c;最后发现是 es的 jar包 和 mq的 netty包 有冲突。然后去idea的 jar包依赖里面查看&#xff0c;mq使用的 是 而es依赖的netty 是多个 不同的包&#xff0c; 而在依赖…

Windows平台下搭建自己的Git服务器

Gitblit 是一个纯 Java 库用来管理、查看和处理 Git 资料库&#xff0c;相当于 Git 的 Java 管理工具。 Gitblit 支持Linux操作系统&#xff0c;因此 Gitblit 需要java运行环境&#xff08;JRE&#xff09;。 如果公司要搭建自己的 Git 服务器&#xff0c;可以使用 Gitblit 这个…

Python 基本数据类型 (二) - 字符串

str.expandtabs([tabsize]): str类型的expandtabs函数&#xff0c;有一个可选参数tabsize&#xff08;制表符大小&#xff09;详细来说&#xff0c;expandtabs的意思就是&#xff0c;将字符串中的制表符\t&#xff0c;全部用空格来替换。至于用多少个空格&#xff0c;需要参考制…

如何预防后台被攻击?Tomcat 的安全配置来啦!

安全是系统架构中最重要的关注点之一&#xff0c;通常情况下&#xff0c;所说的安全涵盖网络安全、数据安全、操作系统安全、服务器安全以及应用系统安全等诸多方面。Tomcat 是一个免费的开放源代码 的Web应用服务器&#xff0c;技术先进、性能稳定。由于它优秀的稳定性以及丰富…

Spring Boot 单例模式中依赖注入问题

在日常项目开发中&#xff0c;单例模式可以说是最常用到的设计模式&#xff0c;项目也常常在单例模式中需要使用 Service 逻辑层的方法来实现某些功能。通常可能会使用 Resource 或者 Autowired 来自动注入实例&#xff0c;然而这种方法在单例模式中却会出现 NullPointExceptio…

VO,BO,PO,DO,DTO的区别

面对这个图&#xff0c;让我们先从承上启下的DTO开始入手 DTO&#xff08;Data Transfer Object&#xff09;数据传输对象 这个传输通常指的前后端之间的传输 DTO是一个比较特殊的对象&#xff0c;他有两种存在形式&#xff1a; 在后端&#xff0c;他的存在形式是java对象&…

Windows下pip 离线包安装

pip在线安装十分方便&#xff0c;有时候某些服务器并没有直接联网&#xff0c;需要下载好安装包上传到服务器上进行安装&#xff0c;不经常用&#xff0c;还是有点小麻烦的。 安装Python之后&#xff0c;将下载好的安装包包放在Python安装的根目录下使用pip install packagenam…

VMware设置及linux静态ip设置

1. VMWARE虚拟机NAT模式上网设置 1.1. VM虚拟机设置 1.1.1. 虚拟机全局设置 启动虚拟机选择【虚拟网络编辑器】 如果需要管理员权限点【更改设置】&#xff0c;没有提示这忽略这一步 选择NAT模式&#xff0c;更改下面的子网IP&#xff0c;改成你需要的任何一个子网网段&…

问题 L: 超超的中等意思

问题 L: 超超的中等意思 时间限制: 1 Sec 内存限制: 128 MB提交: 366 解决: 27[提交] [状态] [命题人:jsu_admin]题目描述 已知p,q,k和一个难搞得多项式(pxqy)^k。想知道在给定a和b的值下计算多项式展开后x^a*y^b得系数s。输入 多组输入&#xff0c;每组数据一行输入p,q,k,a,…

SELinux 引起的 Docker 启动失败

问题描述 Linux OS 版本 CentOS Linux release 7.2.1511 (Core) 启动Docker service docker start 启动失败信息 原因分析 Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel or disabl...nab…

postgresql模糊匹配正则表达式性能问题

postgresql 模糊匹配 目前建议使用like&#xff0c;~~,不建议使用正则表达式&#xff0c; 目前有性能问题https://yq.aliyun.com/articles/405097正则表达式效率比较低下&#xff1a;操作符 ~~ 等效于 LIKE&#xff0c; 而 ~~* 对应 ILIKE。 还有 !~~ 和 !~~* 操作符 分别代表 …

配置MySQL的环境变量

配置MySQL的环境变量 1.现在安装MySQL ——–下载最新版MySQL软件&#xff0c;将MySQL安装到系统目录中&#xff0c;记录当前安装目录&#xff1b; 如安装mysql到D:\wamp\mysql目录下 2.打开win7系统——右击计算机——单击属性-弹出win7系统页面 3.高级系统设置-环境变…

通过mysqldump备份数据库

使用mysqldump命令备份 mysqldump命令的作用是备份MySQL数据库。是将数据库中的数据备份成一个文本文件。表的结构和表中的数据将存储在生成的文本文件中。mysqldump命令的工作原理很简单。它先查出需要备份的表的结构&#xff0c;再在文本文件中生成一个CREATE语句。然后&…