2020年10月17日

摘要: 1 from random import randint 2 from itertools import permutations 3 #4个数组和3个运算符可能组成的表达式形式 4 exps = ('((%s %s %s) %s %s) %s %s', 5 '(%s %s %s) %s (%s % 阅读全文

posted @ 2020-10-17 21:16 黑炽 阅读(99) 评论(0) 推荐(0) 编辑

摘要: 1 #事先声明,这里的 + - * / 按照的是 出现顺序直接计算,并没有考虑优先级 2 def operator(a, op, b): 3 if op == '+': 4 return a+b 5 elif op == '-': 6 return a-b 7 elif op == '*': 8 r 阅读全文

posted @ 2020-10-17 20:14 黑炽 阅读(225) 评论(0) 推荐(0) 编辑

2020年10月16日

摘要: 1 def print_yanghui_triangle(t): 2 list_result = [[] for i in range(t)]#存放结果的双重列表 3 #创建一个包含t个列表的列表 4 for i in range(t): 5 list_result[i].append(1)#结果列 阅读全文

posted @ 2020-10-16 23:44 黑炽 阅读(353) 评论(0) 推荐(0) 编辑

摘要: 1 n = int(input('输入一个n的值:')) 2 for i in range(1, n, 1): 3 # center() 返回一个原字符串居中,并使用空格填充至长度 width 的新字符串。默认填充字符为空格 4 print((' * ' * i).center(n * 3))#打印 阅读全文

posted @ 2020-10-16 20:55 黑炽 阅读(21283) 评论(0) 推荐(0) 编辑

摘要: 1 def C(n, i): 2 #isinstance(object, classinfo) 3 #如果参数object是classinfo的实例,或者object是classinfo类的子类的一个实例, 4 #返回True。如果object不是一个给定类型的的对象, 则返回结果总是False。 阅读全文

posted @ 2020-10-16 16:06 黑炽 阅读(3385) 评论(0) 推荐(0) 编辑

摘要: 1 n = int(input('Input an integer: ')) 2 if n == 2: 3 print('Yes') 4 elif n % 2 == 0: 5 print('No') 6 else: 7 m = n % 6 8 #因为大于5的素数必然出现在6的倍数两侧 9 #6x+2 阅读全文

posted @ 2020-10-16 15:54 黑炽 阅读(1701) 评论(0) 推荐(0) 编辑

摘要: 1 import time 2 3 date = time.localtime() 4 year, month, day = date[:3] 5 day_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] 6 7 if year % 4 阅读全文

posted @ 2020-10-16 11:23 黑炽 阅读(287) 评论(0) 推荐(0) 编辑

摘要: 1 numbers = [] #使用列表存放临时数据 2 while True: 3 x = input('请输入一个成绩: ') 4 #检查是不是浮点数 5 try: 6 numbers.append(float(x)) 7 except: 8 print('不是合法成绩') 9 10 while 阅读全文

posted @ 2020-10-16 11:00 黑炽 阅读(8040) 评论(0) 推荐(0) 编辑

2020年10月12日

摘要: 具体的参照该网址: https://www.cnblogs.com/zhangtianq/p/5839909.html 实现如下:不过解释 或者说怎么实现的在上面网址 1 #include<cstdio> 2 #include<cstring> 3 #define N 10 4 5 int next 阅读全文

posted @ 2020-10-12 21:39 黑炽 阅读(83) 评论(0) 推荐(0) 编辑

摘要: 幂集,就是一个集合的所有子集,包括空集 下面附着代码,具体实现的过程代码下面: 各部分代码如下: 首先是 headF.h(headFile的意思) 1 #pragma once 2 3 #include<cstdio> 4 #include<vector> 5 6 using namespace s 阅读全文

posted @ 2020-10-12 19:45 黑炽 阅读(612) 评论(0) 推荐(0) 编辑