摘要: 思路来自算法图解, 比自己写的更pythonic。 def fun(list): if len(list) < 2: return list else: pivot = list[0] low = [i for i in list[1:] if i <= pivot] high = [i for i 阅读全文
posted @ 2018-03-31 19:44 Ruohua3kou 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 从2.x过渡到3.x的时候,遇到了大大小小的坑,于是便记录下来~ 1.print: 3.x 所有print都要加 "( )",print更像(就是)一个函数了。 2.x 可以加"( )"也可以不加 2.除法: 3.x print(3/2) #1.5 2.x print 3/2 #1 3.range与 阅读全文
posted @ 2018-03-31 17:36 Ruohua3kou 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 转载于知乎刘奕聪的方法 一 f = [1, 1]print([f.append((f[-1] + f[-2])) or f.pop(0) for i in range(100)]) /// f.append()返回none值,所以靠f.pop来输出f。 二 print(reduce(lambda f 阅读全文
posted @ 2018-03-23 11:25 Ruohua3kou 阅读(166) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <windows.h> #define P(S) WaitForSingleObject(S,INFINITE)//定义Windows下的P操作#define V(S) ReleaseSemaphore(S,1,NULL)//定义Windows下 阅读全文
posted @ 2018-03-22 20:19 Ruohua3kou 阅读(2238) 评论(0) 推荐(0) 编辑
摘要: 利用切片操作,实现一个trim()函数,去除字符串首尾的空格 def trim(s): if s[:1] != ' ' and s[-1:] != ' ': return s elif s[:1] == ' ': return trim(s[1:]) else: return trim(s[:-1] 阅读全文
posted @ 2018-03-14 14:53 Ruohua3kou 阅读(632) 评论(0) 推荐(0) 编辑
摘要: 模拟实验楼提供的一个网页。。 【可由 git clone https://github.com/shiyanlou/finaltest 获取相关图片素材】 <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>TEST 阅读全文
posted @ 2018-03-08 21:13 Ruohua3kou 阅读(271) 评论(0) 推荐(0) 编辑
摘要: list中保留四字母的,然后return。 解 def friend(x): i = len(x) ii = [] a = 0 while a < i: if len(x[a]) == 4: ii.append(x[a]) a += 1 return ii 别人的超pythonic的题解。。 def 阅读全文
posted @ 2018-03-06 21:02 Ruohua3kou 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 思路: N 为1或质数 先手必赢 N 为质数X质数的积 后手必赢 先手取两个质数的积则赢 #include #include #define ll long long using namespace std; int main() { int n; cin>>n; while(n--) { ll n 阅读全文
posted @ 2017-11-14 22:35 Ruohua3kou 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 题目: //QQ是一个9位数,由1,2,3,4,5,9组成,且第1、6位数字相同,第2、4位数字相同,第5、7位数字相同。 //我的QQ就在符合上诉条件中的所有9位数从小到大排第50个 很丑的六循环,想知道别的解法 可是 我 找 不 到!! #include <iostream>#include < 阅读全文
posted @ 2017-11-08 17:34 Ruohua3kou 阅读(196) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <algorithm>#include <string>using namespace std;void DFS(string a,int i,int j){ if(i>=j) cout<<a<<endl; else for(int k=i;k 阅读全文
posted @ 2017-11-08 16:51 Ruohua3kou 阅读(80) 评论(0) 推荐(0) 编辑