C++内置的数组支持容器的机制,可是它不支持容器抽象的语义。要解决此问题我们自己实现这种类。在标准C++中,用容器向量(vector)实现。容器向量也是一个类模板。标准库vector类型使用须要的头文件:#include
。vector 是一个类模板。不是一种数据类型,vector是一种数据类型。V...
分类:
编程语言 时间:
2014-06-09 22:57:13
阅读次数:
331
题目
Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not c...
分类:
其他好文 时间:
2014-06-08 05:32:21
阅读次数:
196
题目
Given two sorted integer arrays A and B, merge B into A as one sorted array.
Note:
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional el...
分类:
其他好文 时间:
2014-06-08 05:05:47
阅读次数:
268
统计一个一维数组中的各个元素的个数,然后删除多出来的重复元素,并输出新的数组结果。
例如:[1,2,2,2,3,3,3,3,3]-->[1,2,3]...
分类:
其他好文 时间:
2014-06-08 04:12:33
阅读次数:
221
数组是一个存储多个相同类型的值的有序列表。相同的值,可以在不同的位置出现在一个数组中的多个次。
Swift数组是具体的。他不同于Objective-C的的NSArray和NSMutableArray里的类,它可以存储任何类型的对象,不提供有关它们返回的对象的性质的任何信息。在斯Swift,一个特定的数组可以存储的值类型总是明确的,无论是通过显式类型批注,或通过类型推断,而不一定是类类型。如果创...
分类:
其他好文 时间:
2014-06-08 04:08:27
阅读次数:
289
题目来源:Light OJ 1026 Critical Links
题意:输出桥
思路:模版
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 10010;
struct Edge
{
int u, v;
Edge(){}
Edge(int u, int v):...
分类:
其他好文 时间:
2014-06-08 04:07:05
阅读次数:
235
题目
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.
...
分类:
其他好文 时间:
2014-06-08 04:01:05
阅读次数:
240
求两个排序数组的中位数。这个题可以有以下几个思路:
首先可以想到的是将两个数组merge起来,然后返回其中位数。
第二个是,类似merge的思想加上计数,找到(m+n)/2个数或者其前后的数,这个就可以算出中位数。这个方法对于各种情况需要一一考虑到。
第三个,假设A[k/2-1]<B[k/2-1],那么A[k/2-1]之前的数一定在整个有序数列中(m+n)/2之前。
这里我给出后面两种思路的代码。
代码一( 思路三)...
分类:
其他好文 时间:
2014-06-08 03:44:47
阅读次数:
231
[布尔教育PHP就业班课堂案例]玩游戏,不如自己写游戏!打开浏览器,打开编辑器(sublime,editplus,notepad都行),花上2个小时,写个"别踩白块"玩一玩.JS游戏_别踩白块(1)思路分析.wmvJS游戏_别踩白块(2)框架搭建.wmvJS游戏_别踩白块(3)之随机黑白块.wmvJS游戏_别踩白块(4)方块动起来...
分类:
Web程序 时间:
2014-06-08 02:32:18
阅读次数:
283
1.多项式的系数存放在数组中
# include
# include
# define max(x,y) ((x)>(y)?(x):(y))
using namespace std;
const int N=100;
struct poly
{
int arr[N];
int mexp;
};
void add(poly &a,poly &b,poly &c)
{
memset(c.ar...
分类:
其他好文 时间:
2014-06-08 02:17:57
阅读次数:
264