摘要: 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 阅读(17) 评论(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 阅读(37) 评论(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 阅读(33) 评论(0) 推荐(0)
摘要: t = ([1,2,3],[2,3,4],3) print(t) t[0][1]=9 print(t) # ~ t[2]=9#TypeError: 'tuple' object does not support item assignment # ~ print(t) ''' ([1, 2, 3], 阅读全文
posted @ 2024-01-18 16:24 Kazuma_124 阅读(21) 评论(0) 推荐(0)
摘要: m = 10 a = 10 print(id(m)) print(id(a)) '''输出 140713874176728 140713874176728 ''' print() a = 1 b = 2 c = 3 d = a+b print('a(1)\t'+str(id(a))) print(' 阅读全文
posted @ 2024-01-18 12:06 Kazuma_124 阅读(24) 评论(0) 推荐(0)
摘要: def f(x,li=[1]): print(id(li)) li.append(x) print(li) f('a')#第一次调用函数 print() f('b')#第二次调用函数 print() f('a',[])#第三次调用函数 print() f('b',[2,2])#第四次调用函数 pri 阅读全文
posted @ 2024-01-17 12:01 Kazuma_124 阅读(19) 评论(0) 推荐(0)
摘要: #include <stdio.h> int main() { float a; scanf("%.3f", &a);//输入1234 printf("%f", a);//输出123.000000 printf("%d", (4,3));//3 printf("%d",(3,4));//4 } 阅读全文
posted @ 2024-01-10 19:43 Kazuma_124 阅读(34) 评论(0) 推荐(0)
摘要: #include <stdio.h> int main() { int i = 1; int a = (++i) + (++i); printf("a = %d,i = %d\n", a, i);//a = 6,i = 3 i = 1; a = (++i) + (i = 100); printf(" 阅读全文
posted @ 2023-12-27 11:02 Kazuma_124 阅读(24) 评论(0) 推荐(0)
摘要: 向函数传入某数组时,可以在函数内修改该数组的元素。 #include <stdio.h> void test(char* p, char arr[]) { *p = 'h';//能改变 *arr = 'h';//能改变 *(p + 1) = 'e';//能改变 *(arr + 1) = 'e';// 阅读全文
posted @ 2023-12-25 16:22 Kazuma_124 阅读(31) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <string.h> #define MAX 500 void test() { char arr1[] = { '1','2','3','4','\0','5','6','7','8' }; char arr2[] = { 'a','a',' 阅读全文
posted @ 2023-12-25 15:14 Kazuma_124 阅读(25) 评论(0) 推荐(0)