最新发布第32页
排序
【Python】第一次实验
1 # 1、编写程序,生成一个包含20个随机整数的列表,然后对其中偶数下标的元素进行降序排列,奇数下标的元素不变。(提示:使用切片。) import random l1 = [random.randint(1,100) for i i...
【人工智能】仁爱人工智能路线
一、学习C++(大一 10月-1月) 大一进社团验收完C语言后开始学习C++,学到泛型即可(便于理解为什么python中不需要定义数据的类型)。 二、python基础和Anaconda的安装(大一1月-2月) 取消数据...
【递归】快速幂
class Solution: def myPow(self, x: float, n: int) -> float: if n==0: return 1 if n==1: return x if n==-1: ...
【递归】2的幂
递归法: class Solution: def isPowerOfTwo(self, n: int) -> bool: if n==1: return True if n<=0 or n%2!=0: return Fals...
【递归】斐波那契数
#include<iostream> using namespace std; int fib(int n){ if (n<2){ return n; } return fib(n-1) + fib(n-2); } int main(){ int n; cin >> n; cout << fib(n); return 0; } 数...
【模拟】旋转矩阵
#include<stdio.h> int main(){ int n; scanf('%d',&n); int a[n][n]; int top=0,down=n-1,left=0,right=n-1,count=1; while(count<=n*n){ for (int i=left;i<=right;i++){ a[top]...