This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def odd(n): | |
return n%2 | |
li=[1,2,3,5,9,10,256,-3] | |
filter(odd,li) //输出[1,3,5,9,-3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def double(n): | |
return n*2 | |
li=[5,'a',(2,'b')] | |
map(double,li) //返回[10,'aa',(2,'b',2,'b')] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
#coding=utf-8 | |
def mean(sorted_list): | |
if not sorted_list: | |
return ([],[]) | |
big=sorted_list[-1] | |
small=sorted_list[-2] | |
big_list,small_list=mean(sorted_list[:-2]) | |
big_list.append(small) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "highgui.h" | |
#include "cv.h" | |
#include <stdio.h> | |
#define MAX_CORNERS 50 | |
int capture_data() | |
{ | |
CvCapture* capture; | |
IplImage* frame; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct Pig | |
{ | |
Pig() | |
{ | |
call(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
//无法使用typeof,因为这是gcc的扩展 | |
//#define foreach(container,it) for(typeof((container).begin()) it=(container).begin();it!=(container).end();++it) | |
#define foreach(type,container,it) for(type::iterator it=(container).begin();it!=(container).end();++it) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://zhedahht.blog.163.com/blog/static/25411174200732711051101/ 我是倒这过来做的 | |
#include <stdio.h> | |
void print_sequence(int small,int big) | |
{ | |
int i; | |
for(i=small;i<=big;i++) | |
printf("%d ",i); | |
printf("\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define BITNUMBER 32 //int占4个字节 | |
#define N 32000 | |
int a[N/BITNUMBER+1]; | |
void set(int i) | |
{ | |
a[i/BITNUMBER]|=1<<(i%BITNUMBER); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define BITNUMBER 32 | |
#define N 10000000 | |
#define random(x) rand()%x | |
int a[N/BITNUMBER+1]; | |
void set(int i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*2010/11/18 shihongzhi | |
* 实现了printf,itoa,ftoa | |
* todo:%f的自定义小数点没有实现 | |
*/ | |
#include <stdio.h> | |
#include <stdarg.h> | |
#include <math.h> | |
const double eps=1e-12; |
OlderNewer