在Spring AMQP项目中Spring也提供了对RabbitMQ的支持,这里在之前学习SpringBoot的时候也整合过,但是今天这里使用的Spring的xml配置来整个rabbit.

Spring AMQP项目地址:https://spring.io/projects/spring-amqp;

下面来看看使用方式。

1. 引入依赖

pom文件如下:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.rabbitmq.wangx</groupId>
<artifactId>rabbitmq</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging> <name>rabbitmq Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<spring.framework.version>4.3.9.RELEASE</spring.framework.version>
<spring.amqp.version>2.1.1.RELEASE</spring.amqp.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.test.failure.ignore>false</maven.test.failure.ignore>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.8.0-beta2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.8.0-beta2</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.framework.version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2</version>
<scope>runtime</scope>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency> <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.22</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.22</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.22</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
<version>${spring.amqp.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>${spring.amqp.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency> </dependencies> <build>
<finalName>rabbitmq</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

2. 配置基础信息

  rabbitMQ.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!--配置connection-->
<rabbit:connection-factory id="connectionFactory" host="127.0.0.1" port="5672" username="wangx" password="wangx" virtual-host="/wangx"/> <!--使用admin管理factory-->
<rabbit:admin connection-factory="connectionFactory"/>
<!--定义模板,并指定交换机或queue-->
<rabbit:template id="rabbitTemplate" connection-factory="connectionFactory" exchange="spring-exchange"/>
<!--定义消费者所对应的key-->
<rabbit:queue name="spring-queue" auto-declare="true"/>
<!--声明fanout的交换机-->
<rabbit:fanout-exchange name="spring-exchange" auto-declare="true">
<rabbit:bindings>
<rabbit:binding queue="spring-queue"/>
</rabbit:bindings>
</rabbit:fanout-exchange> <!--声明监听容器-->
<rabbit:listener-container connection-factory="connectionFactory">
<!--指定监听器所对应的bean和方法-->
<rabbit:listener ref="consumer" method="listen" queue-names="spring-queue"/>
</rabbit:listener-container>
<!--消费者监听方法-->
<bean id="consumer" class="com.wangx.rabbitmq.spring.Consumer"/>
</beans>

  消费者:

  Consumer

package com.wangx.rabbitmq.spring;

public class Consumer {

    //对应监听器中所指定的method
public void listen(String msg) {
System.out.println("Spring Consumer 接收到消息:" + msg);
}
}

  发送消息:

package com.wangx.rabbitmq.spring;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; public class Producer {
public static void main(String[] args) {
//读取配置文件
ApplicationContext context = new ClassPathXmlApplicationContext("rabbitMQ.xml");
//获取模板类
RabbitTemplate template = context.getBean(RabbitTemplate.class);
String str = "Spring-message";
//构建MessageProperties对象
MessageProperties messageProperties = new MessageProperties();
//设置参数
messageProperties.setContentEncoding("UTF-8");
messageProperties.setContentType("text/plain");
//构建消息对象
Message message = new Message(str.getBytes(), messageProperties);
//使用模板发送消息
template.send(message);
}
}

  注意:

 messageProperties.setContentEncoding("UTF-8");
messageProperties.setContentType("text/plain");
这两个参数必须要配置,否则会报如下异常:
D:\devsoft\jdk1.8\jdk1.8\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:58888,suspend=y,server=n -javaagent:C:\Users\xing.wang\.IntelliJIdea2018.1\system\captureAgent\debugger-agent.jar=file:/C:/Users/xing.wang/AppData/Local/Temp/capture.props -Dfile.encoding=UTF-8 -classpath "D:\devsoft\jdk1.8\jdk1.8\jre\lib\charsets.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\deploy.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\access-bridge-64.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\cldrdata.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\dnsns.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\jaccess.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\jfxrt.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\localedata.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\nashorn.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\sunec.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\sunjce_provider.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\sunmscapi.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\sunpkcs11.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\ext\zipfs.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\javaws.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\jce.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\jfr.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\jfxswt.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\jsse.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\management-agent.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\plugin.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\resources.jar;D:\devsoft\jdk1.8\jdk1.8\jre\lib\rt.jar;D:\dev-idea\middle\rabbitmq\target\classes;D:\repository\com\rabbitmq\amqp-client\5.5.0\amqp-client-5.5.0.jar;D:\repository\org\slf4j\slf4j-api\1.7.22\slf4j-api-1.7.22.jar;D:\repository\org\slf4j\slf4j-simple\1.8.0-beta2\slf4j-simple-1.8.0-beta2.jar;D:\repository\org\springframework\spring-core\4.3.9.RELEASE\spring-core-4.3.9.RELEASE.jar;D:\repository\org\springframework\spring-context\4.3.9.RELEASE\spring-context-4.3.9.RELEASE.jar;D:\repository\org\springframework\spring-aop\4.3.9.RELEASE\spring-aop-4.3.9.RELEASE.jar;D:\repository\org\springframework\spring-beans\4.3.9.RELEASE\spring-beans-4.3.9.RELEASE.jar;D:\repository\org\springframework\spring-expression\4.3.9.RELEASE\spring-expression-4.3.9.RELEASE.jar;D:\repository\org\springframework\spring-messaging\4.3.9.RELEASE\spring-messaging-4.3.9.RELEASE.jar;D:\repository\org\springframework\spring-tx\4.3.9.RELEASE\spring-tx-4.3.9.RELEASE.jar;D:\repository\cglib\cglib-nodep\2.2\cglib-nodep-2.2.jar;D:\repository\org\slf4j\jcl-over-slf4j\1.7.22\jcl-over-slf4j-1.7.22.jar;D:\repository\org\slf4j\slf4j-log4j12\1.7.22\slf4j-log4j12-1.7.22.jar;D:\repository\log4j\log4j\1.2.14\log4j-1.2.14.jar;D:\repository\org\springframework\amqp\spring-amqp\2.1.1.RELEASE\spring-amqp-2.1.1.RELEASE.jar;D:\repository\org\springframework\retry\spring-retry\1.2.2.RELEASE\spring-retry-1.2.2.RELEASE.jar;D:\repository\org\springframework\amqp\spring-rabbit\2.1.1.RELEASE\spring-rabbit-2.1.1.RELEASE.jar;D:\devsoft\idea\IntelliJ IDEA 2018.1.4\lib\idea_rt.jar" com.wangx.rabbitmq.spring.Producer
Connected to the target VM, address: '127.0.0.1:58888', transport: 'socket'
INFO [t.support.ClassPathXmlApplicationContext]: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@3fee9989: startup date [Mon Nov 19 16:22:38 CST 2018]; root of context hierarchy
INFO [eans.factory.xml.XmlBeanDefinitionReader]: Loading XML bean definitions from class path resource [rabbitMQ.xml]
INFO [ontext.support.DefaultLifecycleProcessor]: Starting beans in phase 2147483647
INFO [bbit.connection.CachingConnectionFactory]: Attempting to connect to: 127.0.0.1:5672
INFO [bbit.connection.CachingConnectionFactory]: Created new connection: connectionFactory#47caedad:0/SimpleConnection@2c4d1ac [delegate=amqp://wangx@127.0.0.1:5672//wangx, localPort= 58894]
WARN [istener.ConditionalRejectingErrorHandler]: Execution of Rabbit message listener failed.
org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Failed to invoke target method 'listen' with argument type = [class [B], value = [{[B@3f099764}]
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:387)
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:292)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1511)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1434)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1421)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1400)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:848)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:832)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$700(SimpleMessageListenerContainer.java:78)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1073)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodException: com.wangx.rabbitmq.spring.Consumer.listen([B)
at java.lang.Class.getMethod(Class.java:1786)
at org.springframework.util.MethodInvoker.prepare(MethodInvoker.java:174)
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:365)
... 10 more
WARN [ingErrorHandler$DefaultExceptionStrategy]: Fatal message conversion error; message rejected; it will be dropped or routed to a dead letter exchange, if so configured: (Body:'[B@3f099764(byte[14])' MessageProperties [headers={}, contentType=application/octet-stream, contentLength=0, receivedDeliveryMode=PERSISTENT, priority=0, redelivered=false, receivedExchange=spring-exchange, receivedRoutingKey=, deliveryTag=1, consumerTag=amq.ctag-ZbVlvRKHCdm3KFhzW5uu8A, consumerQueue=spring-queue])
ERROR [.listener.SimpleMessageListenerContainer]: Execution of Rabbit message listener failed, and the error handler threw an exception
org.springframework.amqp.AmqpRejectAndDontRequeueException: Error Handler converted exception to fatal
at org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler.handleError(ConditionalRejectingErrorHandler.java:106)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeErrorHandler(AbstractMessageListenerContainer.java:1334)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.handleListenerException(AbstractMessageListenerContainer.java:1585)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1415)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:848)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:832)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$700(SimpleMessageListenerContainer.java:78)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1073)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Failed to invoke target method 'listen' with argument type = [class [B], value = [{[B@3f099764}]
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:387)
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:292)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1511)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1434)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1421)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1400)
... 5 more
Caused by: java.lang.NoSuchMethodException: com.wangx.rabbitmq.spring.Consumer.listen([B)
at java.lang.Class.getMethod(Class.java:1786)
at org.springframework.util.MethodInvoker.prepare(MethodInvoker.java:174)
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:365)
... 10 more
 

RabbitMQ学习笔记(5)----RabbitMQ整合Spring的更多相关文章

  1. [RabbitMQ学习笔记] - 初识RabbitMQ

    RabbitMQ是一个由erlang开发的AMQP的开源实现. 核心概念 Message 消息,消息是不具名的,它由消息头和消息体组成,消息体是不透明的,而消息头则由 一系列的可选属性组成,这些属性包 ...

  2. Mybatis学习笔记(八) —— Mybatis整合spring

    一.整合思路 1.SqlSessionFactory对象应该放到spring容器中作为单例存在. 2.传统dao的开发方式中,应该从spring容器中获得sqlsession对象. 3.Mapper代 ...

  3. RabbitMQ学习笔记五:RabbitMQ之优先级消息队列

    RabbitMQ优先级队列注意点: 1.只有当消费者不足,不能及时进行消费的情况下,优先级队列才会生效 2.RabbitMQ3.5以后才支持优先级队列 代码在博客:RabbitMQ学习笔记三:Java ...

  4. RabbitMQ学习笔记(五) Topic

    更多的问题 Direct Exchange帮助我们解决了分类发布与订阅消息的问题,但是Direct Exchange的问题是,它所使用的routingKey是一个简单字符串,这决定了它只能按照一个条件 ...

  5. RabbitMQ学习笔记1-hello world

    安装过程略过,一搜一大把. rabbitmq管理控制台:http://localhost:15672/   默认账户:guest/guest RabbitMQ默认监听端口:5672 JAVA API地 ...

  6. (转) Rabbitmq学习笔记

    详见原文: http://blog.csdn.net/shatty/article/details/9529463 Rabbitmq学习笔记

  7. 官网英文版学习——RabbitMQ学习笔记(十)RabbitMQ集群

    在第二节我们进行了RabbitMQ的安装,现在我们就RabbitMQ进行集群的搭建进行学习,参考官网地址是:http://www.rabbitmq.com/clustering.html 首先我们来看 ...

  8. 官网英文版学习——RabbitMQ学习笔记(一)认识RabbitMQ

    鉴于目前中文的RabbitMQ教程很缺,本博主虽然买了一本rabbitMQ的书,遗憾的是该书的代码用的不是java语言,看起来也有些不爽,且网友们不同人学习所写不同,本博主看的有些地方不太理想,为此本 ...

  9. Spring框架学习笔记(5)——Spring Boot创建与使用

    Spring Boot可以更为方便地搭建一个Web系统,之后服务器上部署也较为方便 创建Spring boot项目 1. 使用IDEA创建项目 2. 修改groupid和artifact 3. 一路n ...

  10. Spring实战第四章学习笔记————面向切面的Spring

    Spring实战第四章学习笔记----面向切面的Spring 什么是面向切面的编程 我们把影响应用多处的功能描述为横切关注点.比如安全就是一个横切关注点,应用中许多方法都会涉及安全规则.而切面可以帮我 ...

随机推荐

  1. SVN仓库导入文件

    分两种: 1.导入文件版本库从0开始 (适合新项目) 2.将其他SVN服务器中的版本库导入进来,版本库继承原SVN服务器的(适合SVN版本库迁移) 第一种: #mkdir –p /home/code/ ...

  2. 34.初识搜索引擎及timeout机制

    主要知识点 1.对搜索执行结果的说明 2.timeout机制讲解 一.对执行 GET /_search 的结果的说明 执行结果如下(只保留部分) { "took": 29, &qu ...

  3. 数据持久层(DAO)通用API的实现

    在Web开发中,一般都分3层.Controller/Action 控制层,Service/Business 服务层/业务逻辑层,Dao 数据访问层/数据持久层. 在学习和工作的实践过程中,我发现很多功 ...

  4. MYSQL更换密码

    MYSQL5.7以下版本的数据库密码使用的是 mysql这个数据库里的user表的password这个字段, 修改密码只需: 1.update MySQL.user set password=pass ...

  5. NYIST 914 Yougth的最大化

    Yougth的最大化时间限制:1000 ms | 内存限制:65535 KB难度:4 描述 Yougth现在有n个物品的重量和价值分别是Wi和Vi,你能帮他从中选出k个物品使得单位重量的价值最大吗? ...

  6. Linux中tty是什么(tty1~7)

    tty:终端设备的统称. tty一词源于Teletypes,或者teletypewriters,原来指的是电传打字机,是通过串行线用打印机键盘通过阅读和发送信息的东西,后来这东西被键盘与显示器取代,所 ...

  7. NEFU 115

    刚开始,做了水题 #include <iostream> #include <cstdio> #include <algorithm> using namespac ...

  8. Linux Terminal fortune

    Linux下,我们能够使用apt-get安装fortune,这是一个比較有趣的功能 在输入fortune之后,Terminal会输出一句名言.诗句,或一些有趣的话: 默认情况下.fortune仅仅会显 ...

  9. C++实现顺序栈的基本功能

    栈是限定仅在表头进行插入和删除操作的线性表.有着先进后出的特点(FILO): 如今我来动手实现栈的基本本功能练练手: 定义栈的头文件例如以下: #ifndef CSTOCK_H_ #define CS ...

  10. 【BZOJ 2982】 combination

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2982 [算法] lucas定理 [代码] #include<bits/stdc ...