#include<bits/stdc++.h> using namespace std; vector<,); 定义一个大小为9,初始化全是1的vector数组 set<int> s; queue<int> q; int main() { for(auto i:v) // 遍历vector printf("%d ",i); v.push_back();插入一个数据 printf(]); v.clear();清除vector数组 printf(&…
1.string 1>substr(),截取字串的方法.返回一个从指定位置开始,并具有指定长度的子字符串.参数 start(必选),所需的子字符串的起始位置.字符串中第一个字符的索引为 0.length(可选项).返回的子字符串中包含的字符数.第二个参数是指定子串的长度备注.如果 length为0或负数,将返回一个空字符串.如果没有指定length参数,则子字符串将延续到字符串的结尾. 2>insert() iterator insert( iterator loc, const TYPE &…
1.关联容器和顺序容器 C++中有两种类型的容器:顺序容器和关联容器,顺序容器主要有:vector.list.deque等.关联容器主要有map和set.如下图: 1.vector基本使用 #include <iostream> #include <stdlib.h> #include <string.h> #include <algorithm> #include <vector> using namespace std; //利用模版进行输出…
编程题常用知识点的review. most important: 想好(1)详尽步骤(2)边界特例,再开始写代码. I.vector #include <iostream> //0.头文件. 特性: 连续存储,动态双倍分配增长 #include <vector> #include <algorithm> //relevant using namespace std; bool comp(int a,int b){ return a>b; } int main(){…
目录 头文件 string 目录部分 1.string的定义及初始化 ① 用一个字符串给另一个字符串赋值 ②用字符串常量对字符串进行赋值 ③ 用n个相同的字符对字符串赋值 2.string的运算符及比较符 3.string的一些常用函数 ① size()和length() ② at() ③ find() ⑤ append() stack 目录部分 1.stack的定义 2.常用函数 ① size() ② empty() ③ pop() 与 top() ④ push() queue 目录部分 1.…
在cocos2dxv3.0beta之前存在顺序性容器cocos2d::CCArray,和cocos2d::CCDictionary.可是在新版本号之后这两个容器都将被cocos2d::Vector<T>和cocos2d::Map<k,V>取代. 1. cocos2d::Vector<T> cocos2d::Vector<T>是一个封装了动态大小的数组的顺序型容器. 它的元素是连续存储的.cocos2d::Vector<T> 的存储是自己主动处理的…
集合--List 栈先进后出 队列 先进先出 Queue队列 方法 Queue<Integer> q = new LinkedList<>(); //添加元素 q.add(2); q.add(3); q.add(4); //获取队列长度 int len = q.size(); //获取头元素但不删除,空会引发异常 int ele1 = q.element(); //获取但不删除头元素,空会返回null int ele2 = q.peek(); //获取并删除头元素 int ele3…
vector.queue.stack.priority_queue对元素进行元素访问时,返回的是对应元素的引用.…
http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in th…
数组 数组是值类型,因此改变副本的值,不会影响到本身 数组的定义:var 变量名 [元素数量] T 变量名(符合标识符要求即可) 元素数量(整型,可以是const中的值) T(可以是任意基本类型,包括数组本身,当类型为数组时,可以实现多维数组) var a [5]int 和 var a [10]int 是不同的类型 定义一个字符串数组,然后赋值: var team [3]string team[0] = "hammer" team[1] = "soldier" te…