fu

集合

こ雲淡風輕ζ 提交于 2019-12-02 22:53:01
集合是无序可变,元素不能重复。实际上,集合底层是字典实现,集合的所有元素都是字典 中的“键对象”,因此是不能重复的且唯一的。 集合的创建 1.{}创建 a = {"kang","fu",23} print(type(a)) print(a) 运行结果: <class 'set'> {'fu', 'kang', 23} 2.set()创建,将列表、元组等可迭代对象转成集合。如果原来数据存在重复数据,则只保留一个。 a = set(("kang","fu",23,"fu")) b = set(["fu",18,"IT"]) print(type(a)) print(a) print(type(b)) print(b) 运行结果: <class 'set'> {'fu', 'kang', 23} <class 'set'> {'fu', 18, 'IT'} 集合的增加 使用add()方法 a = set(("kang","fu",23,"fu")) a.add(40) print(a) 运行结果: {40, 'fu', 'kang', 23} 集合的删除 1.remove()删除指定元素 a = set(("kang","fu",23,"fu")) a.remove(23) print(a) 运行结果: {'fu', 'kang'} 2.clear()方法整个清除 a = set((

java 继承访问成员变量

北城以北 提交于 2019-12-02 00:20:16
package java09; //创建父类 public class Fu { int numFu = 10; int num =100; public void methodFu(){ System.out.println(num); } } package java09; //创建子类 public class Zi extends Fu { int numZi = 20; int num =200; public void methodZi(){ System.out.println(num); } } package java09; /* 在父类的继承关系中,如果成员变量重名,则创建子类对象时,访问有两种方式: 直接通过子类对象访问成员变量: 等号左边是谁就优先用谁,没有则向上找 间接通过成员方法访问成员变量: 该方法属于谁,就优先用谁,没有则向上找 * */ public class DemoExtendsField { public static void main(String[] args) { Fu fu = new Fu();//创建父类对象 System.out.println(fu.numFu);//10 只能使用父类的东西,没有任何子类的内容 System.out.println("=============="); Zi zi = new Zi();

【模板整合计划】高阶数据结构—线段树

倖福魔咒の 提交于 2019-12-01 20:00:14
【模板整合计划】高阶数据结构—线段树 【学习笔记】线段树详解(全) 一:【基本操作及扩展】 1.【区间修改(+),区间查询(Sum)】 【模板】线段树 \(1\) \(\text{[P3372]}\) #include<cstdio> #define Re register int #define LL long long #define pl p<<1 #define pr p<<1|1 const int N=1e5+3; struct QAQ{int l,r;LL S,add;}Q[N<<2]; int i,b,c,d,e,n,m,fu,a[N]; inline void creat(Re p,Re l,Re r){ Q[p].l=l,Q[p].r=r; if(l==r){Q[p].S=a[l];return;} Re mid=l+r>>1; creat(pl,l,mid),creat(pr,mid+1,r); Q[p].S=Q[pl].S+Q[pr].S; } inline void spread(Re p){ if(Q[p].add){ LL a=Q[p].add; Q[pl].S+=a*(Q[pl].r-Q[pl].l+1); Q[pr].S+=a*(Q[pr].r-Q[pr].l+1); Q[pl].add+=a,Q[pr].add+=a,Q[p].add=0; }

你真的懂Spring Java Config 吗?Full @Configuration vs lite @Bean mode

主宰稳场 提交于 2019-12-01 07:06:16
Full @Configuration 和 lite @Bean mode 是 Spring Java Config 中两个非常有意思的概念。 先来看一下官方文档关于这两者的相关内容: The @Bean methods in a regular Spring component are processed differently than their counterparts inside a Spring @Configuration class. The difference is that @Component classes are not enhanced with CGLIB to intercept the invocation of methods and fields. CGLIB proxying is the means by which invoking methods or fields within @Bean methods in @Configuration classes creates bean metadata references to collaborating objects. Such methods are not invoked with normal Java semantics but rather go through

2-8 符号配对

霸气de小男生 提交于 2019-11-30 04:26:16
请编写程序检查C语言源程序中下列符号是否配对:/ 与 /、(与)、[与]、{与}。 输入格式: 输入为一个C语言源程序。当读到某一行中只有一个句点.和一个回车的时候,标志着输入结束。程序中需要检查配对的符号不超过100个。 输出格式: 首先,如果所有符号配对正确,则在第一行中输出YES,否则输出NO。然后在第二行中指出第一个不配对的符号:如果缺少左符号,则输出?-右符号;如果缺少右符号,则输出左符号-?。 输入样例1: void test() { int i, A[10]; for (i=0; i<10; i++) /*/ A[i] = i; } . 输出样例1: NO /*-? 输入样例2: void test() { int i, A[10]; for (i=0; i<10; i++) /**/ A[i] = i; }] . 输出样例2: NO ?-] 输入样例3: void test() { int i double A[10]; for (i=0; i<10; i++) /**/ A[i] = 0.1*i; } . 输出样例3: YES 我的答案 提示: 如果最后一个测试用例过不去,可能是 /* 和 */ 的问题. 方法一(运行时处理) // // Created by 小邋遢 on 2019/9/19. // #include <bits/stdc++.h> using

11-多态

放肆的年华 提交于 2019-11-30 02:46:37
目录 多态 概述 多态的具体情况 多态下的成员特点 成员方法 转型 向上转型 向下转型 instanceof 总结 什么时候转型 多态的好处和缺点 额外 多态 概述 例如:Student类继承了Person类,那么Student的对象,即是一个Student也是Person。 表示:可以将子类(实现类)对象赋值给该类的引用变量,也可以将子类(实现类)对象赋值给父类的引用变量。 代码的最终体现:父类的引用变量指向子类对象。 代码:Person p = new Student();//就像int x = (byte)4; 注:多态必须在继承的前体下。(普通继承,抽象类,接口) 多态的具体情况 类继承普通类 class Fu{ } class Zi{ public static void main(String[] args) { Fu fu = new Zi(); } } 类继承抽象类 abstract class Fu{ } class Zi extends Fu{ public static void main(String[] args) { Fu fu = new Zi(); } } 实现类实现接口 interface Fu { } class Zi implements Fu{ public static void main(String[] args) { Fu fu =

opengl版本

大城市里の小女人 提交于 2019-11-28 05:42:13
OpenGL vendor string: Intel OpenGL renderer string: Intel(R) HD Graphics 630 OpenGL version string: 4.4.0 - Build 21.20.16.4664 OpenGL extensions (GL_): GL_3DFX_texture_compression_FXT1, GL_AMD_depth_clamp_separate, GL_AMD_vertex_shader_layer, GL_AMD_vertex_shader_viewport_index, GL_ARB_ES2_compatibility, GL_ARB_ES3_compatibility, GL_ARB_arrays_of_arrays, GL_ARB_base_instance, GL_ARB_bindless_texture, GL_ARB_blend_func_extended, GL_ARB_buffer_storage, GL_ARB_cl_event, GL_ARB_clear_buffer_object, GL_ARB_clear_texture, GL_ARB_clip_control, GL_ARB_color_buffer_float, GL_ARB_compatibility, GL_ARB

State Function Approximation: Linear Function

点点圈 提交于 2019-11-27 06:42:15
In the previous posts, we use different techniques to build and keep updating State-Action tables. But it is impossible to do the same thing when the number of states and actions get huge. So this post we gonna discuss about using a parameterized function to approximate the value function. Basic Idea of State Function Approximation Instead of looking up on a State-Action table, we build a black box with weights inside it. Just tell the blackbox whose value functions we want, and then it will calculate and output the value. The weights can be learned by data, which is a typical supervised