Skip to content

Instantly share code, notes, and snippets.

View topin27's full-sized avatar

YangTianping topin27

  • ChongQing University
  • Chengdu,China
View GitHub Profile
@topin27
topin27 / .rtorrent.rc
Created January 8, 2023 10:26 — forked from wangyan/.rtorrent.rc
This is an Chinese example resource file for rTorrent.
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
# 每个种子所允许的最小最大连接数
#min_peers = 40
#max_peers = 100
# 同上,但仅针对已完成的种子(-1 表示与下载中的种子一致)
#min_peers_seed = 10
--[[ The nasty OO
Animal = {
size=1, age=2,
sleep = function (self)
print("I need sleep.")
print("size"..self.size.."\tage"..self.age)
end
}
@topin27
topin27 / cpp-lua.cpp
Created March 29, 2013 02:27
C++与Lua之间的相互调用接口
/*先是C++调用Lua。
*/
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
#include <cstdio>
using std::printf;
@topin27
topin27 / match.cpp
Created September 22, 2012 09:16
在一个字符串中寻找简单的符合正则表达式的字串,并将其保存到目的数组中,中间用空格间隔。
/*
* 字符串匹配问题,给定一串字符串,按照指定规则对齐进行匹配,并将匹配结果
* 保存至output数组中,多个匹配项用空格间隔,最后一个不需要空格。 要求:
* 1、匹配规则中包含通配符?和*。?表示匹配任意一个字符,*表示匹配任意
* 多个字符串。
* 2、匹配后的输入串不再进行匹配,从当前匹配后的字符串开始重新匹配其
* 它字符串。
*/
#include <iostream>
#include <string>
@topin27
topin27 / expression.cpp
Created September 17, 2012 02:52
华为的一道上机题,一个简单的计算算术表达式(带括号)的程序,没有使用传统的栈来解决。
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cstdlib>
using namespace std;
static int simple_arithmetic(const string &k_expression_) // No any brakets.
@topin27
topin27 / huawei.cpp
Created April 14, 2012 02:02
华为的三道上机题
// =======================
// 华为的三道上机题,
// 第一题是求出一个数组中的最小数;
// 第二题是检验密码字符串,要求长度在8~128之间,并且同时有
// 大写字符、小写字符、数字,同时没有空格。
// 第三题是斗地主规则,A用1表示、K用13表示等等。
// 要求根据相应的牌型返回相应的代码号(其中3代1不考虑,
// 只有3个相同的情况)。
// =======================
@topin27
topin27 / huiwen.py
Created April 13, 2012 03:31
计算字符串是否是“回文串”
def foo(s_, i_ = 0):
strLen = len(s_)
if strLen == 0:
return False
if i_ < 0:
return False
if i_ == (strLen / 2 - 1):
return s_[i_] == s_[strLen - 1 - i_]
return (s_[i_] == s_[strLen - 1 - i_] and foo(s_, i_ + 1))
@topin27
topin27 / tece.cpp
Created April 13, 2012 02:10
已知数组a,给数组b赋值,b[i]=a[0]*a[1]*...a[N]/a[i],要求时间复杂度为O(n),除了迭代下标,不能另外声明变量,同时不能用除法。
#include <iostream>
using namespace std;
void foo(int *p_a_, int *p_b_, int n_);
int main()
{
int a[] = {1, 2, 3, 4, 5};
int b[] = {1, 1, 1, 1, 1};