简介 简单工厂模式还是得修改factory类来构建出新的对象. 工厂方法模式将factory也抽象成一个抽象接口 code public interface Car { void name(); } public interface CarFactory { Car getCar(); } publ ...
分类:
其他好文 时间:
2021-06-02 12:58:35
阅读次数:
0
描述:编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串 ""。例如输入:strs = ["flower","flow","flight"],输出:"fl"。输入:strs =["dog","racecar","car",输出:""。 思路一:横向扫描,从第一个开始,把第 ...
分类:
编程语言 时间:
2021-06-02 12:53:32
阅读次数:
0
1、 #include <stdio.h> int str_char(char x[], int key) { int len = 0; while(x[len]) len++; int i; for(i = 0; i < len; i++) { if(x[i] == key) return i; ...
分类:
编程语言 时间:
2021-06-02 12:49:19
阅读次数:
0
1、controller中的方法 /** * 获取区域树 * @return */ @ResponseBody @RequestMapping("/getAreaInfoTree") public List<AreaInfo> getAreaInfoTree(){ List<AreaInfo> re ...
分类:
编程语言 时间:
2021-06-02 12:47:27
阅读次数:
0
LeetCode415. 字符串相加 题目描述 /** * * 给定两个字符串形式的非负整数 num1 和num2 ,计算它们的和。 * */ 思路分析 按照多位数加法列竖式计算的方式 定义一个可变长字符串保存计算的结果,定义一个carry保存对应两位是否有进位 将每次计算的结果以字符从形式追加到字 ...
分类:
其他好文 时间:
2021-06-02 12:43:28
阅读次数:
0
1、 #include <stdio.h> #define NUMBER 5 int main(void) { char str[NUMBER][128]; int i; for(i = 0; i < NUMBER; i++) { printf("str[%d] = ", i); scanf("%s ...
分类:
编程语言 时间:
2021-06-02 12:43:03
阅读次数:
0
看代码: 1 int cal(int n) { 2 int sum = 0; 3 int i = 1; 4 for (; i <= n; ++i) { 5 sum = sum + i; 6 } 7 return sum; 8 } 从cpu角度来看,这段代码每一行都执行类似操作 读数据-运算-写数据 ...
分类:
编程语言 时间:
2021-06-02 12:25:48
阅读次数:
0
一开始看错题目惹,导致错过了这题的关键$trick$ 考虑每次操作肯定都是一个$[k,n]$的,证明贪心一下就好了。 那么考虑记$f[i][k]$为前$i$个数用了$k$次。 那么只要满足$j < i \ and\ a_j + k_j ? a_i + k_i \ and\ k_j < k_i$就能转 ...
分类:
其他好文 时间:
2021-06-02 12:06:04
阅读次数:
0
通用装饰器 def wrapper(fun): def inner(*args,**kwargs): print(f"before execute target {fun} ") ret=fun() print(f"after execute target {fun}") return ret re ...
分类:
其他好文 时间:
2021-06-02 12:04:33
阅读次数:
0
import os import time import smtplib from email.mime.text import MIMEText from email.header import Header sender = '2575125xxx@qq.com' receivers = ['1 ...
分类:
编程语言 时间:
2021-06-02 11:42:46
阅读次数:
0