Sequence

[PAT] 1148 Werewolf

风流意气都作罢 提交于 2020-05-06 07:18:38
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: "Player #2 is a werewolf."; player #2 said: "Player #3 is a human."; player #3 said: "Player #4 is a werewolf."; player #4 said: "Player #5 is a human."; and player #5 said: "Player #4 is a human.". Given that there were 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. Can you point out the werewolves? Now you are asked to solve a harder version of this problem: given that there

PAT(A) 1148 Werewolf

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-06 07:08:23
题目链接: 1148 Werewolf - Simple Version (20 point(s)) Description Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: “Player #2 is a werewolf.”; player #2 said: “Player #3 is a human.”; player #3 said: “Player #4 is a werewolf.”; player #4 said: “Player #5 is a human.”; and player #5 said: “Player #4 is a human.”. Given that there were 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. Can you point out the werewolves? Now you are asked

1148 Werewolf

佐手、 提交于 2020-05-06 03:38:13
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 said: "Player #2 is a werewolf."; player #2 said: "Player #3 is a human."; player #3 said: "Player #4 is a werewolf."; player #4 said: "Player #5 is a human."; and player #5 said: "Player #4 is a human.". Given that there were 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. Can you point out the werewolves? Now you are asked to solve a harder version of this problem: given that there

Oracle 创建触发器实现自增长

前提是你 提交于 2020-05-05 21:52:15
Oracle中没有主键,要实现自增长,需要创建触发器,每次插入数据的时候进行ID赋值。 环境:Oracle11,Navicat工具连接 创建了一个表,字段如下( 字段名,表名都需要大写,你小写了还无效。。。 ): -- 如果表中存在记录,先把原来的数据赋值 UPDATE VD_EVENTS_DATA SET ID = ROWNUM; -- 创建序列,设置初始值和每次增长值 CREATE SEQUENCE VD_EVENTS_DATA_ID_SEQ MINVALUE 1 NOMAXVALUE INCREMENT BY 1 START WITH 1000 NOCACHE; -- 创建触发器,请注意这个格式。。。 CREATE OR REPLACE TRIGGER VD_EVENTS_DATA_INS_TRG BEFORE INSERT ON VD_EVENTS_DATA FOR EACH ROW WHEN (NEW.ID IS NULL OR NEW.ID = 0 ) BEGIN SELECT VD_EVENTS_DATA_ID_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; END ; / 如果出现下面错误: ORA-24344: success with compilation error 成功,但编译出错 你会发现你的触发器创建成功了

MySQL导入csv文件内容到Table及数据库的自增主键设置

余生长醉 提交于 2020-05-05 21:42:27
写在前面 目的是测试将csv文件内容导入到表中, 同时记录一下自增主键的设置. 测试采用MySQL8.0. 新建表customer_info如下, 未设置主键. 修改上表, 添加主键id, 并设置为自增. ALTER TABLE customer_info ADD COLUMN id INT AUTO_INCREMENT NOT NULL PRIMARY KEY ; 导入步骤 1.为了模拟数据, 直接把这三条记录导出到csv文件中. 2.将该文件导入到表customer_info中. csv文件中没有表头, 第一行就是数据, 所以改为1; 字段名行: 1这个没改, 点下一步如下: 3.验证导入结果 刷新表, 查看导入结果, 确实是从文件中的第一条数据张三开始导入的.文件内容已完全导入到表中. 小结 MySQL新增自增主键 ALTER TABLE customer_info ADD COLUMN id INT AUTO_INCREMENT NOT NULL PRIMARY KEY ; MySQL修改字段为自增主键 ALTER TABLE customer_info CHANGE COLUMN id id INT AUTO_INCREMENT PRIMARY KEY ; 如果id本身就是主键, 仅仅是想设置为自增上面sql就不需要加PRIMARY KEY了.

Thymeleaf对象的使用:数字对象

假装没事ソ 提交于 2020-05-05 16:18:53
Thymeleaf主要使用 org.thymeleaf.expression.Numbers 类处理数字,在模板中使用 #numbers 对象来处理数字。 开发环境:IntelliJ IDEA 2019.2.2 Spring Boot版本:2.1.8 新建一个名称为demo的Spring Boot项目。 pom.xml加入Thymeleaf依赖: < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-thymeleaf </ artifactId > </ dependency > 一、整数格式化 有4个方法: (1)formatInteger(number,digits) 第一个参数为单个数字,如果有小数字点则四舍五入,第二个参数设置最少的整数位数,不足会补0(下同) (2)arrayFormatInteger(numbers,digits) 传入数组,返回处理后的数组 (3)listFormatInteger(numbers,digits) 传入List,返回处理后的List (4)setFormatInteger(numbers,digits) 传入Set,返回处理后的Set 这4个方法存在重载方法传入第三个参数,用于标识千位分隔符

python学习笔记(二) python3中为什么range(1,3)==[1,2],return False

穿精又带淫゛_ 提交于 2020-05-05 13:57:53
本文主要参考(可能需要科学上网): [1] https://www.pythoncentral.io/pythons-range-function-explained/ [2] https://justindailey.blogspot.com/2011/09/python-range-vs-xrange.html 工作环境是Ubuntu14.04LTS下terminal。 一般Ubuntu都会帮我们安装好python,按“ctrl+alt+t”就可以进入terminal。系统里面一般还会备有两个版本的python:python2.x和python3.x。直接输入python的话能够启动系统中的python2.x版本,如果想启动python3.x版本,就使用python3命令。运行也是一样,启动python2.x版本程序直接使用python name.py就行,如果想让python3.x来运行的话,就使用python3 name.py命令。 range是一个比较基础的函数,可以用他来生成我们想要的数字序列。之前用的python2.x版本,他直接就返回的是一个list,所以之前没注意。现在用python3,抱着好奇的心态在命令行中试了下:range(1, 3) == [1, 2]没想到居然返回了False,这让我一时半会儿很懵。 网上找了找,看了看几个帖子之后,解决了心中的疑惑

C 语言面试题 — int i [ 4 ]={ i [ 2 ]=2 }

僤鯓⒐⒋嵵緔 提交于 2020-05-05 13:02:46
目录 文章目录 目录 题目 题目 # include <stdio.h> int main ( void ) { int i [ 4 ] = { i [ 2 ] = 2 } ; printf ( "%d %d %d %d\n" , i [ 0 ] , i [ 1 ] , i [ 2 ] , i [ 3 ] ) ; return 0 ; } 本题考察的是 Sequence Point(序列点)问题。即 int i[4] = {i[2] = 2}; 写法具有双重初始化的顺序问题,即 int i[4]={2} 和 i[2]=2 谁先执行。 关于这一点,C标准是这样阐述的: The evaluations of the initialization list expressions are indeterminately sequenced with respect to one another and thus the order in which any side effects occur is unspecified. 。也就是说初始化表达式计算顺序不确定! 到这里就很清晰了,无非就是 i[2]=2 和 int i[4]={2} 产生的 side effects(边缘影响)谁先谁后的问题。但是有一点我们要明确:无论谁先谁后, i[0]=2 这一点可以肯定,因为一维数组不完全初始化

小记----Mybatis

北战南征 提交于 2020-05-05 02:33:24
使用mybatis操作数据库有两种方式xml注入和@注解方式,两种方式在项目中是可以共存的。 注解方式:使用注解方式 默认 需要实体类的属性值和表的列名保持一致,否则无法映射到对应的值;或者使用@Results来手动设置映射关系,优点:看着优雅一点,方便修改,缺点:动态sql语句不好写,比较麻烦 xml形式:很常用的方式,有各种逆向工程可以生成mapper.xml文件,看着比较乱,各种标签满天飞,修改的时候很痛苦 我们会发现无论是hibernate还是mybatis,为了方便我们的写sql都煞费苦心。但最后他们都殊途同归指向了“约定大于配置”。hibernate搞了个jpa,而mybatis也相应推出了mp。而mp 是一个 MyBatis 的增强工具 。 看看官网对他的介绍: 无侵入 :只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑 损耗小 :启动即会自动注入基本 CURD,性能基本无损耗,直接面向对象操作 强大的 CRUD 操作 :内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求 支持 Lambda 形式调用 :通过 Lambda 表达式,方便的编写各类查询条件,无需再担心字段写错 支持主键自动生成 :支持多达 4 种主键策略(内含分布式唯一 ID 生成器 - Sequence)