This file contains hidden or 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> | |
//strtok的实现和strtok_r一样,只是用一个static char*来维护saveptr | |
char *strtok_r(char *str,const char *delim,char **saveptr) | |
{ | |
char *ret; | |
if(str==NULL) | |
str=*saveptr; |
This file contains hidden or 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
#输出最后一位校验码 | |
print (12-reduce(lambda x,y:x+y,map(lambda x:int(x[0])*x[1],zip('330225198708292872'[0:17],[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1])))%11)%11 |
This file contains hidden or 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
reduce(lambda x,y:x+y,map(lambda x:str(x).count('1'), [t for t in range(13+1)])) |
This file contains hidden or 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
import glob,os | |
if __name__ == '__main__': | |
p=r'E:\test1\*.jpg' | |
li = glob.glob(p) | |
k = 0 | |
for f in li: | |
i = f.rindex('\\') | |
j = f.rindex('.') | |
newf = f.replace(f[i+1:j],'%04d'%(k)) |
This file contains hidden or 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://stackoverflow.com/questions/5037187/formatted-input-in-python/5040181#5040181 题解 | |
f=open("x.txt") | |
d={} | |
flag=False | |
for l in f.readlines(): | |
if not flag: | |
num=(len(l)-1)/2 | |
flag=True | |
continue | |
for i in range(num): |
This file contains hidden or 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
# coding=gbk | |
import re | |
import urllib | |
#如何把name的编码转换成中文? | |
if __name__=='__main__': | |
f = open("touxiang.txt") | |
text = f.read() | |
l = text.split('},{') | |
re.findall(r'"name":"(.*)","head":"(.*)","groups":',text) | |
k = 1 |
This file contains hidden or 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
import maya.cmds as cmds | |
f1 = open(r"C:\Users\shihongzhi\Desktop\newproject\test\sparse3dpoint-absolute.txt") | |
i = 0 | |
for line in f1.readlines()[40:]: | |
if i%6 == 0: | |
point = [float(t) for t in line[:-2].split(" ")] | |
#cmds.spaceLocator(p=(point[0],point[1],point[2])) | |
cmds.sphere(p=point,r=0.01) | |
elif i%6 == 1: |
This file contains hidden or 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 MAX 7 | |
int cake[MAX][MAX],diff[MAX][MAX-1]; | |
int min = 100000; | |
void compute(int m, int n, int r, int v) | |
{ |
This file contains hidden or 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://blog.codingnow.com/2006/02/double_to_int_magic_number.html | |
//http://www.cnblogs.com/Xiao_bird/archive/2010/03/26/1696908.html %f--8bytes %lf--8bytes %d--4bytes | |
#include <stdio.h> | |
union luai_Cast { double l_d; long l_l; }; | |
#define lua_number2int(i,d) { volatile union luai_Cast u; \ | |
u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } | |
int main() | |
{ |
This file contains hidden or 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
/* 来至 Quake 3 的源码 */ | |
//求得的是 开平方的倒数,具体原理不懂 | |
float CarmSqrt(float x){ | |
union{ | |
int intPart; | |
float floatPart; | |
} convertor; | |
union{ | |
int intPart; | |
float floatPart; |