摘要: // 害死人不偿命的(3n + 1)思想 #include <iostream> #include <string> using namespace std; int main() { int n = 0; int step = 0; cin >> n; while (n != 1) { if (n 阅读全文
posted @ 2022-03-08 23:33 W-forever 阅读(50) 评论(0) 推荐(0)
摘要: #include <iostream> #include <string> #include <vector> using namespace std; int main() { //了解一下二维数组的性质 int a[3][4] = { {1, 3, 5, 7}, {2, 4, 6, 8}, {1 阅读全文
posted @ 2022-03-08 22:37 W-forever 阅读(39) 评论(0) 推荐(0)
摘要: #include <iostream> #include <string> #include <vector> using namespace std; void biaoDaShi() { //在一条语句中混用解引用和递增运算符 vector<int>v = { 0 }; auto pbeg = 阅读全文
posted @ 2022-03-08 14:52 W-forever 阅读(27) 评论(0) 推荐(0)
摘要: #include<iostream> #include<string> #include<vector> using namespace std; void test() { //string对象的定义和初始化 string s1; string s2 = s1; string s3 = "hiya 阅读全文
posted @ 2022-03-07 10:12 W-forever 阅读(34) 评论(0) 推荐(0)
摘要: #include <iostream> //一个使用io输入输出对象 void test(); int main() { std::cout << "Enter two numbers" << std::endl; int v1 = 10; int v2 = 0; std::cin >> v1 >> 阅读全文
posted @ 2022-03-06 10:37 W-forever 阅读(36) 评论(0) 推荐(0)
摘要: 一.matplotlib 1.1 matplotlib基本命令 1.1.1实现一个简单的matplotlib画图 import matplotlib.pyplot as plt plt.figure() plt.plot([1, 0, 9], [4, 5, 6]) plt.show() 1.1.2 阅读全文
posted @ 2021-11-08 21:12 W-forever 阅读(104) 评论(0) 推荐(0)
摘要: class Solution: def maxProfit(self, prices: List[int]) → int: minprice = prices[0] maxprofit = 0 for i in prices: minprice = min(minprice, i) maxprofi 阅读全文
posted @ 2021-06-24 00:33 W-forever 阅读(36) 评论(0) 推荐(0)
摘要: class Solution: def canPlaceFlowers(self, flowerbed: List[int], n: int) → bool: if len(flowerbed) == 1: if flowerbed[0] == 0: return 1 >= n else: retu 阅读全文
posted @ 2021-06-24 00:32 W-forever 阅读(38) 评论(0) 推荐(0)
摘要: 53.最大子序和 思路:用两个值分别记录当前一直连续加过来的最大值,还有一个记录整个数组的最大值,并适时更新他们得值 class Solution: def maxSubArray(self, nums: List[int]) -> int: #初始化最大值,和当前值 maxsum = nums[0 阅读全文
posted @ 2021-06-23 11:55 W-forever 阅读(17) 评论(0) 推荐(0)
摘要: 455.分发饼干 思路:贪心算法,先满足要求最小的孩子的需求 class Solution: def findContentChildren(self, g: List[int], s: List[int]) → int: i = 0 j = 0 #进行排序 g.sort() s.sort() #记 阅读全文
posted @ 2021-06-23 11:41 W-forever 阅读(28) 评论(0) 推荐(0)