摘要: 实验 向零取整 int a = 8; int b = 3; int c = 6; int d1 = a / b; // 8 / 3 = 2 ( 2.667 --> 2) int d2 = a / c; // 8 / 6 = 1 ( 1.333 --> 1) int d3 = -a / b; // - 阅读全文
posted @ 2024-05-17 23:27 Kazuma_124 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ​ 代码运行到第4行,getchar()需要输入的数据,但是输入的缓冲区没有数据,所以就需要再命令行窗口(黑窗口)输入新的数据 ​ 这时候getchar()只需要输入1个字符的数据,但是你可以输入多个数据,打回车的时候之前输入的一行数据都会被发送到缓冲区,回车之前都还可以删除刚才输入的数据修改修改, 阅读全文
posted @ 2024-05-16 13:44 Kazuma_124 阅读(10) 评论(0) 推荐(1) 编辑
摘要: C语言 #sscanf #代码学习 #codewars 题目链接:IP Validation | Codewars 代码如下: #include <stdio.h> int is_valid_ip(const char *addr) { unsigned n[4], i, nc; // Must b 阅读全文
posted @ 2024-02-06 21:01 Kazuma_124 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.codewars.com/kata/5426d7a2c2c7784365000783/python def balanced_parens(n): ''' To construct all the possible strings with n pairs of b 阅读全文
posted @ 2024-02-06 11:41 Kazuma_124 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.codewars.com/kata/5426d7a2c2c7784365000783/python 我的解决方案: def balanced_parens(n): # Your code here! used_l=[False for i in range(n)] 阅读全文
posted @ 2024-02-05 14:26 Kazuma_124 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 题目的要求是写一个Sudoku类,类中要有一个实例函数判断传给对象的二维数组是否符合数独规则 题目链接:https://www.codewars.com/kata/540afbe2dc9f615d5e000425/python 下面是写完题后看到的别人的解决方法 from itertools imp 阅读全文
posted @ 2024-02-03 19:09 Kazuma_124 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 做题的时候有的测试点里竟然用True替换1,骗过了我的代码,结果没过测试点 lst = [1, True] for item in lst: if not isinstance(item, bool) and item == 1: print(item) 阅读全文
posted @ 2024-02-02 22:09 Kazuma_124 阅读(2) 评论(0) 推荐(0) 编辑
摘要: def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a 阅读全文
posted @ 2024-01-29 17:38 Kazuma_124 阅读(1) 评论(0) 推荐(0) 编辑
摘要: class pers(): def __init__(self,hp): self._hp=hp @property def hp(self): return self._hp @hp.setter def hp(self,hp): self._hp=gp if hp>=0 else 0 a=per 阅读全文
posted @ 2024-01-27 16:09 Kazuma_124 阅读(7) 评论(0) 推荐(0) 编辑
摘要: class test(): aaa = 111 bbb = 222 ccc = 333 @classmethod def cm(cls): cls.aaa="***" def im(self): self.aaa="iii" aa = test() print(aa.aaa,aa.bbb,aa.cc 阅读全文
posted @ 2024-01-27 15:11 Kazuma_124 阅读(9) 评论(0) 推荐(0) 编辑