最新发布第31页
排序
【递归】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]...
【模拟】各位相加
#include<iostream> using namespace std; int main(){ int num; cin >> num; while(num>9){ int total=0; while(num!=0){ total+=num%10; num/=10; } num = total; total = 0; } cout <&...
【模拟】二进制求和
#include <iostream> using namespace std; string addBinary(string a, string b){ string res; int carry = 0; // 进位 int i = a.size() - 1; int j = b.size() - 1; while(i >= 0 || j...
【Python】学生信息管理系统示例
import os.path #导入os.path模块 def menm(): #菜单 print('==========================学生信息管理系统==========================') print('----------------------------...