学习了scala模式匹配下的赋值语句,模式匹配完成a和b的绑定,a@b其中a是b的别名,1000赋值给a和b,用元组的方式接收了1000和2000,二元组必须小写,大写会认为是常量,如果是大写要先定义,也可通过数组的方式进行赋值,例子如下Defmain(args:Array[String]){Val...
分类:
其他好文 时间:
2015-08-03 08:55:43
阅读次数:
255
Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --...
分类:
其他好文 时间:
2015-08-02 23:00:31
阅读次数:
103
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
/*
* 单链表的插入排序, 插入排序是一种稳定排序
*/
class Solution7 {
public:
ListNode* insertionSortList(ListNod...
分类:
编程语言 时间:
2015-08-02 21:38:44
阅读次数:
169
class Solution {public: int removeElement(vector& nums, int val) { vector new_nums; int i=0; int s=nums.size(); while(i...
分类:
其他好文 时间:
2015-08-02 21:15:06
阅读次数:
73
题目:求二叉树两个结点的最远距离。二叉树定义如下:class TreeNode{public: int val; TreeNode* left; TreeNode* right; TreeNode(int x):val(x),left(NULL),right(NULL){}}...
分类:
编程语言 时间:
2015-08-02 16:44:56
阅读次数:
158
例子1:class A { val x1: String = "hello" val x2: String = "mom" println("A: x1=" + x1 + ",x2=" + x2)}class B extends A { override val x2: String = "...
分类:
其他好文 时间:
2015-08-02 16:28:59
阅读次数:
112
#include#includetypedef struct _ListNode{ int m_nKey; struct _ListNode *m_pNext;}ListNode;//插入节点void InsertNode(ListNode **plistHead, int val){ ListNo...
分类:
其他好文 时间:
2015-08-02 14:58:59
阅读次数:
91
1、交集 #方法一:
a=[2,3,4,5]
b=[2,5,8]
tmp?=?[val?for?val?in?a?if?val?in?b]
print?tmp
#[2,?5]
#方法二
print?list(set(a).intersection(set(b))) 2、并集 print?list(set(a).union(set(b))...
分类:
其他好文 时间:
2015-08-02 13:52:07
阅读次数:
395
1自定义一个ModelBinder public class filterRule { public string field { get; set; } public string op { get; set; } public string val...
分类:
编程语言 时间:
2015-08-02 11:38:30
阅读次数:
234
scala没有从语法的角度来支持枚举,而是通过定义了一个接口Enumeration来支持的object ExecutorState extends Enumeration{ type ExecutorState = Value val LAUNCHING, LOADING, RUNNING, K.....
分类:
其他好文 时间:
2015-08-01 23:24:57
阅读次数:
198