1. 斐波那契 from itertools import islice def fib(): a, b = 0, 1 while True: yield a a, b = b, a+b print list(islice(fib(), 5)) # [0, 1, 1, 2, 3] 2. for……else……用法(以查找素数为例) 正常版本: def print_prime(n): for i in xrange(2, n): found = True for j in xrange(2, i)…
方法一: public static int indexOf (字符串/字符,int从第几位开始,int共查几位) string tests = "1absjjkcbfka2rsbcfak2bfka1"; //测试字符串 int i = tests.IndexOf("2b",5,tests.Length-5); //查找从第五字符向后查找“2b” textBox2.Text = i.ToString(); int i = tests.IndexO…
Let the Balloon Rise. 最近开始刷hdoj,想通过写博客做做笔记,记录写过代码. Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest i…