size

string的empty,size,length等比较

怎甘沉沦 提交于 2020-02-23 10:49:44
1 #include<iostream> 2 #include<string> 3 4 using namespace std; 5 6 void Display(const string& str) 7 { 8 cout<<"String: "<<str<<endl; 9 cout<<"Empty: "<<str.empty()<<endl; 10 cout<<"Size: "<<str.size()<<endl; 11 cout<<"Length: "<<str.length()<<endl; 12 cout<<"Capacity: "<<str.capacity()<<endl; 13 cout<<"Maxsize: "<<str.max_size()<<endl; 14 cout<<endl; 15 } 16 17 18 int _tmain(int argc, _TCHAR* argv[]) 19 { 20 string s1=""; //无字节 21 Display(s1); 22 23 string s2=" "; //两个空子节 24 Display(s2); 25 26 string s3="123456"; 27 Display(s3); 28 29 string s4="123 456 asd"; 30 Display(s4); 31 32 /* s3

Increasing stack size in browsers

你离开我真会死。 提交于 2020-02-23 10:44:21
问题 Short question: I have a javascript that goes very deep in recursion. How can I increase the stack size so that I can execute it (something like "ulimit -s unlimited" in Unix systems)? Long story: I have to draw a graph and I use Cytoscape JS (http://js.cytoscape.org/) coupled with the Dagre layout extension (https://github.com/cytoscape/cytoscape.js-dagre). The drawing algorithm goes deep in the recursion and I end up getting "Uncaught RangeError: Maximum call stack size exceeded" in Chrome

Increasing stack size in browsers

允我心安 提交于 2020-02-23 10:43:28
问题 Short question: I have a javascript that goes very deep in recursion. How can I increase the stack size so that I can execute it (something like "ulimit -s unlimited" in Unix systems)? Long story: I have to draw a graph and I use Cytoscape JS (http://js.cytoscape.org/) coupled with the Dagre layout extension (https://github.com/cytoscape/cytoscape.js-dagre). The drawing algorithm goes deep in the recursion and I end up getting "Uncaught RangeError: Maximum call stack size exceeded" in Chrome

STL总结之vector

醉酒当歌 提交于 2020-02-21 17:01:47
STL中vector是通常作为数组使用,不过它更像一个动态数组,在实际项目开发中大量使用. 优点:存储空间连续,可以使用下标访问,时间复杂度O(1). 缺点:不适合从中间删除和添加元素. C++标准规定的vector模板声明: template < class T, class Allocator = allocator<T> > class vector; T : 存储的数据类型 Allocator : 存储空间分配器(默认为std::allocator<T>) 1)首先vector可以作为数组使用,因此我们可以在初始化vector时,指定元素个数和初始值. vector<int> v; //v中含有0个元素 vector<int> v(5); //v中含有5个元素 vector<int> v(5, 1); //v中含有5个元素,赋予初始值1 另外vector还可以通过其他方式构造: vector<int> third (v.begin(),v.end()); //通过v构造third vector<int> fourth (third); //通过copy构造 //通过数组进行初始化 int myints[] = {16,2,77,29}; vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );

左外连接 where条件 on条件

我的梦境 提交于 2020-02-20 10:58:52
QL> CREATE TABLE t1 AS SELECT ROWNUM ID FROM dual CONNECT BY ROWNUM<=10; Table created SQL> SELECT * FROM t1; ID ---------- 1 2 3 4 5 6 7 8 9 10 10 rows selected SQL> CREATE TABLE t2 AS SELECT ROWNUM ID,'a'||ROWNUM NAME FROM dual CONNECT BY ROWNUM<=5; Table created SQL> SELECT * FROM t2; ID NAME ---------- ----------------------------------------- 1 a1 2 a2 3 a3 4 a4 5 a5 SQL> SELECT * FROM t1 LEFT OUTER JOIN t2 ON t1.id=t2.ID WHERE t1.id=4; ID ID NAME ---------- ---------- ----------------------------------------- 4 4 a4 SQL> SELECT * FROM t1 LEFT OUTER JOIN t2 ON t1.id=t2.ID WHERE t2.id=4;

java学习first_day

浪尽此生 提交于 2020-02-19 13:48:58
java枚举 public class EnumMethodDemo {   e num Color {RED, GREEN, BLUE;}    enum Size {BIG, MIDDLE, SMALL;}    public static void main (String args[]) {    System.out.println( "=========== Print all Color ===========");    ////  =========== Print all Color ===========                      for (Color c : Color.values()) {                      RED ordinal: 0 GREEN ordinal: 1 BLUE ordinal: 2             System.out.println(c + " ordinal: " + c.ordinal());     }      System.out.println( "=========== Print all Size ===========");      for (Size s : Size.values()) {       System.out.println(s + "

ABC155E - Payment

懵懂的女人 提交于 2020-02-17 21:52:33
简述题意,给你一个大数,你可以选择10的次幂进行加减运算,问如何用最少的次数从0到达这个大数 考虑从这个大数到0,从最低位开始,每次都将这个位置取完,2种策略,贪心的话不好处理进位的情况,可以想到是DP 设dp[i][0]为取到第i位,将第i位直接拿完的最小次数,dp[i][1]为取到第i位,进位后拿完的最小次数,可以得到状态转移,num表示第i位的数字 dp[i][0] = min(dp[i-1][0], dp[i-1][1]+1) + num,dp[i-1][1]-1表示进了一位,所以第i位就要+1 dp[i][1] = 10 - num + min(dp[i-1][0], dp[i-1][1]-1) 同理,dp[i-1][1]进了一位,num相当于(num+1), 10-(num+1) = 10 - num - 1 注意初始化状态,最终取答案的时候要在最高位的下一位统计,因为最高位可能也进位了,相当于放了一个虚0 #include<bits/stdc++.h> using namespace std; #define lowbit(x) ((x)&(-x)) typedef long long LL; const int maxm = 1e6+5; int dp[maxm][2]; void run_case() { string str; cin >> str; dp

蚯蚓2

╄→尐↘猪︶ㄣ 提交于 2020-02-16 18:39:59
本题中,我们将用符号⌊c⌋ 表示对 c 向下取整,例如:⌊3.0⌋=⌊3.1⌋=⌊3.9⌋=3。 蛐蛐国最近蚯蚓成灾了!隔壁跳蚤国的跳蚤也拿蚯蚓们没办法,蛐蛐国王只好去请神刀手来帮他们消灭蚯蚓。 蛐蛐国里现在共有 n 只蚯蚓(n 为正整数)。每只蚯蚓拥有长度,我们设第 i 只蚯蚓的长度为ai,并保证所有的长度都是非负整数(即:可能存在长度为 0 的蚯蚓)。 每一秒,神刀手会在所有的蚯蚓中,准确地找到最长的那一只(如有多个则任选一个)将其切成两半。神刀手切开蚯蚓的位置由常数 p(是满足0<p<1 的有理数)决定,设这只蚯蚓长度为 x,神刀手会将其切成两只长度分别为 ⌊px⌋ 和 x−⌊px⌋ 的蚯蚓。特殊地,如果这两个数的其中一个等于 0,则这个长度为 0 的蚯蚓也会被保留。此外,除了刚刚产生的两只新蚯蚓,其余蚯蚓的长度都会增加 q(是一个非负整常数)。 蛐蛐国王知道这样不是长久之计,因为蚯蚓不仅会越来越多,还会越来越长。蛐蛐国王决定求助于一位有着洪荒之力的神秘人物,但是救兵还需要 m 秒才能到来……(m 为非负整数) 蛐蛐国王希望知道这 m秒内的战况。具体来说,他希望知道: m 秒内,每一秒被切断的蚯蚓被切断前的长度(有 m 个数);m 秒后,所有蚯蚓的长度(有 n+m 个数)。 蛐蛐国王当然知道怎么做啦!但是他想考考你…… 输入格式 第一行包含六个整数 n,m,q,u,v,t

Java 动态数组

末鹿安然 提交于 2020-02-14 23:32:04
什么是数据结构? 线性表 数组 动态数组设计 项目结构 代码实现 CybArrayList.java package com.cyb; /** * 自定义ArrayList数组 * * @author chenyanbin * */ public class CybArrayList { /** * 元素的数量 */ private int size; /** * 所有元素 */ private int[] elements; private static final int DEFAULT_CAPACITY = 100; private static final int ELEMENT_NOT_FOUND = -1; public CybArrayList() { this(DEFAULT_CAPACITY); } public CybArrayList(int capacity) { capacity = (capacity < DEFAULT_CAPACITY) ? DEFAULT_CAPACITY : capacity; elements = new int[capacity]; } /** * 元素的个数 * * @return */ public int size() { return size; } /** * 是否为空 * * @return */ public

iOS-UIScrollView+UIPageControl简单实现

人走茶凉 提交于 2020-02-13 16:37:05
#import "MJViewController.h" #import "RootViewController.h" @interface MJViewController () <UIScrollViewDelegate> @property (strong, nonatomic) UIScrollView *scrollView; @property (strong, nonatomic) UIPageControl *pageControl; @property (strong, nonatomic) UIButton *nextBt; @end @implementation MJViewController - (void)viewDidLoad { [super viewDidLoad]; //初始化视图 NSArray *array = [NSArray arrayWithObjects:[UIColor redColor],[UIColor blueColor],[UIColor yellowColor],[UIColor purpleColor],[UIColor whiteColor], nil]; self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 80, self.view