Ruby 入门随笔变量全局变量定义:在变量名前加"$"
例如:
1$testString = "23333"
类成员123456class test #静态变量(类变量) @@A #普通类成员 @Bend
静态变量(类变量)定义:在变量名前加"@@"
普通类成员定义:在变量名前加"@"
访问类中的变量为变量设置getter方法 123def At @@Aend
这样一来就可以通过 $变量名.At 来调用@@A
通过attr_accessor为指定的属性创建 12345class test @@A @B attr_accessor :A,:Bend
等价于
123456class test @@A @B attr_reader :A,:B attr_writer :A,:Bend
与
1234567891011121314151617class test @@A @B def A @@A ...
计算机语言
未读shell 入门随笔判断1234567if [ command1 ];then codeelif [ command2 ];then codeelse codefi
循环for循环12345678910for 变量 in 列表do codedonefor ((i=0;i<n;i++))do codedone
while循环1234while [ command ]do codedone
文件读取12345cat 文件path | while read -r linedo#在这里line的最后一行有/r换行符,需要用sed过滤掉 newline = $(echo $line | sed 's/\r//')done
注:在声明变量时,变量名与值之间,等于与值之间不能有空格
不要使用rm -rf ./* 这种指令,如果目录不对非常危险,可以先cd..退出目录 ,再rm -rf ./文件夹名/
ArrayList和linkedListhttps://www.cnblogs.com/lingshang/p/10897912.html
List是一个接口,不可以实例化。List有两个重要的实现类:ArrayList和LinkedList
ArrayListArrayList: 可以看作是能够自动增长容量的数组(感觉跟C++STL中的Vector很像也是一个动态数组)ArrayList的toArray方法返回一个数组
ArrayList的asList方法返回一个列表
ArrayList底层的实现是Array, 数组扩容实现
LinkListLinkList是一个双链表,在添加和删除元素时具有比ArrayList更好的性能.但在get与set方面弱于ArrayList.当然,这些对比都是指数据量很大或者操作很频繁。
链表不需要连续的空间, 大小不确定
扩容机制,源码分析等继续参考https://www.cnblogs.com/lingshang/p/10897912.html
IDEA连接mysql-Server returns invalid timezone. Go to Advanced tab and set serverTimezone prope ‘serverTimezone’ prope 没有设置时区并且没有配置mysql匹配的驱动
https://blog.csdn.net/liuqiker/article/details/102455077
计算机语言
未读java的三种随机数生成方式完全取自这篇大佬文章:https://www.cnblogs.com/blogxjc/p/9687297.html
随机数的产生在一些代码中很常用,也是我们必须要掌握的。而java中产生随机数的方法主要有三种:
第一种: new Random()第一种需要借助java.util.Random类来产生一个随机数发生器,也是最常用的一种,构造函数有两个,Random()和Random(long seed)。第一个就是以当前时间为默认种子,第二个是以指定的种子值进行。产生之后,借助不同的语句产生不同类型的数。
种子就是产生随机数的第一次使用值,机制是通过一个函数,将这个种子的值转化为随机数空间中的某一个点上,并且产生的随机数均匀的散布在空间中。以后产生的随机数都与前一个随机数有关。以代码为例。
123456789public static void main(String[] args){ Random r = new Random(1); for(int i=0 ; i<5 ; i++) { int ran1 = r.ne ...
计算机语言
未读常用注解取自B站视频:https://www.bilibili.com/video/BV19K4y1L7MT?p=12&spm_id_from=pageDriver
@Configuration 与 @Bean123456789101112@Configurationpublic class test{ @Bean public User user1(){ return new User("滑稽","18"); } @Bean("tom") public Pet cat(){ return new Pet("tomcat"); }}
@Configuration告诉Springboot这是一个配置类,其作用相当于配置文件
@Configuration(proxyBeanMethods = true)
外部无论对配置类中的这个组件注册方法调用多少次获取的都是之前注册容器中的单实 ...
英语考研规划题型重点把握:阅读和作文
客观题完形填空20*0.5=10要求: 带入符合语境,意思
阅读理解20*2=40发力点在于逻辑关系
1.正向(没有转折句):子的总体趋势相通,都在说一件事【2011-2】The decision to quit a senior position to look for a better one is unconventional. For years executives and headhunters have adhered to the rule that the most attractive CEO candidates are the ones who must be poached. Says Korn/Ferry senior partner Dennis Carey: “I can’t think of a single search I’ve done where a board has not instructed me to look at sitting CEOs first.”28 . ...
参考自官方的博客:https://blog.nowcoder.net/n/699c671bf3e24676a6df403f68686d73
题目题面有一个 n 个数的数组,代表 n 栋建筑,有如下两种操作:
修改:区间 l 到 r 内的建筑增高 k(正整数)
查询:对于某个位置 x,求 y 的数目( y \gt xy>x ,且对于位置 y ,位置 x 到位置 y 的这段区间的最小值是位置 y 的值)
Input第一行两个数字 n 和 m , 表示数字个数和操作个数第二行 n 个数字,表示建筑高度后面 m 行指令:c l r k或者:q x数据范围: 1≤n,m≤2×10^5,1≤l,r≤n1≤x≤n,1≤k≤10^4
Output对于每个查询,输出答案,每个答案一行
ExamplesInput12345675 51 2 3 4 3q 3c 1 3 3q 2c 5 5 4q 5
Output123120
思路思路就是线段树,但是要对val,在l与r区间内能组成下降数列的数不断进行更新(感觉有点像dp了。。。)直接用线段树的话就会超时(还是太菜了)题目中y的数量实际上就是从 ...
参考自大佬的博客:https://blog.csdn.net/gg_gogoing/article/details/38753567
题目题面一个岛上有神与恶魔两个种族,神会说真话,恶魔会说假话。已知神与恶魔的个数,但不知道具体个人是属于哪个。
n,x,y
这个人问n次 ,x为神的个数,y为恶魔的个数。
每次的问题为 xi,yi,a 问xi ,yi是否为神? a为yes/no。注意xi,yi可能为同一个人
若最终可得出哪些是神则从小到大输出神的编号,并最终输出end
否则输出no
Input输入格式如下:
1234567n p1 p2 xl yl a1 x2 y2 a2 ... xi yi ai ... xn yn an
第一行有三个非负整数 n, p1, 和 p2. n 是 Akira 问的问题数. p1 和 p2 是在传说中记载的神族和恶魔族的人口数量。下面的每 n 行包括两个整数xi, yi和一个单词 ai。 xi 和 yi 是每个人的编号,号码范围从 1 到 p1 + p2。 ai 可能是 yes 或者 no。如果居民 xi 想让你认为 yi 是神族,他会回答 ...
参考自大佬的博客:https://www.cnblogs.com/stelayuri/p/12709923.html
题目题面A. Linova and Kingdomtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWriting light novels is the most important thing in Linova’s life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.
There are n cities and n−1 two-way roads connecting pairs of cities in the kingdo ...
题目最长不上升子序列
Input所有输入数据都是非负整数,且小于等于32767。每组数据最后一个数为-1。保证每组数据数量大小不超过1e5
Output每个测试的输出包括一个测试编号以及答案(具体看样例)。每组样例中间有一个空行
ExamplesInput38920715530029917015865-1233421-1-1
OutputTest #1: maximum possible interceptions: 6
Test #2: maximum possible interceptions: 2
代码1234567891011121314151617181920212223242526272829303132333435363738394041424344#include<stdio.h>int num[50000],len;/*num为dp数组,其中的数组地址的值表示长度,而其对应的值表示该长度下的序列末尾数值的最小值*/int solve(int k)/*二分,由于之前的序列都是采用的最优解,所以说长度越长末尾的数就越小,不然则反之利用这一规律用二分来 ...
题目The Triangle
题面73 88 1 02 7 4 44 5 2 6 5
(Figure 1)
Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right.
InputYour program is to read from standard input. The first line contains one integer N: the number of rows in the triangle. The following N lines describe the data of the tri ...








