自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(81)
  • 资源 (1)
  • 收藏
  • 关注

原创 java 讲字符串转换为字符数组

package test;public class stirngtest { public static void main(String args[]){ char a[][]=new char[21][21]; String str=new String("www.runoob.com"); System.out.println("ddd"); System.out.println(str.toCharArray()); .

2020-05-23 21:00:33 248

原创 leetcode--150

class Solution: def evalRPN(self, tokens: List[str]) -> int: s = [] res = 0 if len(tokens)==1: return int(tokens[0]) for i in range(len(tokens)): if tokens[i] == "+": .

2020-05-19 21:01:17 138

原创 牛客网--相反数

n=input()s=int(n)+int(n[::-1])print(s)import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); System.out.println(Integer.parseInt(.

2020-05-18 21:55:43 154

原创 P1451 求细胞数量

n, m = map(int, input().split())temp = [0] * n# vis = [[0] * m] * nvis = [[0 for i in range(m)] for j in range(n)]dir_ = ((1, 0), (0, 1), (-1, 0), (0, -1))ans = 0for i in range(n): temp[i] = (list(input()))def dfs(x, y): for t in range(4.

2020-05-17 23:10:09 189

原创 python 二维数组创建的陷阱

官方文档上的例子。[[]]*3 是指向内部空的list([])的指针,也就是说[[],[],[]]内部的三个list实际上内存地址是相同的,所以不要用这个方法创建二维数组,官方建议用([[] for in range(n)])的方式!!!!!!这个大坑, 坑了我几个小时!!!!!!...

2020-05-16 18:49:10 176

原创 leetcode 1 两数之和

class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i+1,len(nums)): if nums[i]+nums[j]==target: return [i,j] .

2020-05-12 10:01:30 93

原创 java 多线程学习

Java线程的两种创建方式注意 runnable接口的时候需要新建Thread类package com.company;public class Thread1 implements Runnable { @Override public void run() { System.out.println("hello"); } publi...

2020-04-28 18:19:49 83

原创 P1305 新二叉树

```python import sysn = int(sys.stdin.readline().strip())nodes = [0 for i in range(n)]root = 0s1 = []L = [0 for i in range(300)]R = [0 for i in range(300)]for i in range(n): s = input()...

2020-04-20 21:10:07 117

原创 Java求最小值

Java求最小值 import java.io.IOException; import java.util.Scanner;public class Main { public static void main(String[] args) throws IOException { Scanner in=new Scanner(System.i...

2020-04-18 19:31:27 2646

原创 maven 修改地址后 要从新从中央仓库下载到本地

mvn help:system

2020-01-11 18:49:12 606

原创 MacOS 配置java和maven环境变量而且解决mvn -v 警告 “NB: JAVA_HOME should point to a JDK not a JRE”

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Homeexport PATH=$JAVA_HOME/bin:/usr/local/bin:$PATHexport CLASS_PATH=$JAVA_HOME/lib#Mavenexport MAVEN_HOME=/usr/...

2020-01-11 18:35:48 588

原创 IDEA新建Maven项目的Plugins出现红线的解决方法

将pom.xml文件copy到桌面,删除项目中的pom.xml。发现项目maven中没有任何东西后,然后将桌面的pom.xml粘贴到项目目录下,刷新maven就ok了

2020-01-11 17:34:42 591

原创 堆排序 heapsort

#include <iostream> using namespace std; void heapify(int arr[], int n, int i) { int largest = i;int l = 2*i + 1;int r = 2*i + 2;if (l < n &...

2019-12-31 22:05:00 125

原创 java创建对象的方法

package com.company;public class B implements Cloneable { public void hello(){ System.out.println("hello from B"); } protected Object clone() throws CloneNotSupportedException...

2019-12-31 16:01:49 73

原创 java 获取当前工作路径(macOS)

package com.company;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); System.out.println(System.getPro...

2019-12-28 16:49:56 1169

原创 python异常处理

s=input("enter an integer:")try: i=int(s) print("valid integer entered:",i)except ValueError as err: print(err)while True: try: x=int(input("Please enter a number:"))

2017-05-03 14:49:01 604

原创 python随机模块

import randomx=random.randint(1,6)y=random.choice(["apple","banana","cherry","durian"])print(x,y)

2017-05-03 13:51:41 322

原创 二次方程求解

import mathdef main(): print ("let us find the solution to a quadratic\n") a, b, c=eval(input("please input the coefficients(a,b,c):")) delta=b*b-4*a*c if a==0: x=-b/c

2017-05-01 19:17:39 293

原创 python学习

import mathdef main(): print ("this program find the real solution to a quadratic") a, b, c=eval(input("please input the coefficients(a,b,c):")) delta=b*b-4*a*c if delta>=0:

2017-05-01 19:03:22 208

原创 括号匹配问题1153

#include "stdafx.h"#include #include #includeusing namespace std;stack s;char str[100];char ans[110];int _tmain(int argc, _TCHAR* argv[]){while (cin >> str){int i;

2017-04-30 19:53:13 295

原创 前端学习

当line-height和height高度相同时候,居中,其他情况偏上偏下。 Document *{ margin:0; padding:0; } P{ width:600px; height:60px;

2017-03-23 15:10:54 176

原创 含有无符号类型的表达式

#include "stdafx.h"#include#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ for (unsigned u = 10; u >= 0; --u){ cout << u << endl; } return 0;}上述代码有问题,变量u永远也不会小于0

2017-02-25 13:48:02 239

原创 与旧代码的接口(C++中C_str()的用法)

#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ string s("hello world"); char *str = s; cout << *str; const char *str1= s.c_str(); cout << endl << *str1; return 0;}不能用st

2017-02-24 16:59:15 351

原创 字符串

#include#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ const char ca[] = { 'h', 'e', 'l', 'l', 'o' }; const char *cp = ca; while (*cp){ cout << *cp << endl; ++c

2017-02-24 14:58:09 151

原创 比较字符串

#include "stdafx.h"#include#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ string s1 = "A string example"; string s2 = "A different string"; cout << (s2 <s1) << end

2017-02-24 14:48:59 205

原创 前端学习

百度首页为了追求极致的显示速度居然所有的HTML标签都没有换行,都没有缩进。

2017-02-23 15:54:24 201

原创 素数筛法1163

#include "stdafx.h"#include#includeusing namespace std;int prime[10000];int primeSize=0;bool marked[10001] = { false };void init(){ for (int i = 2; i <= 10000; i++) { if (marked[i] == true)

2017-02-20 14:54:15 171

原创 素数测试1047

#include "stdafx.h"#include#includeusing namespace std;bool judge(int x){ if (x <= 1) return false; int bound = (int)sqrt(x) + 1; for (int i = 2; i <bound; i++){ if (x%i == 0){ return fals

2017-02-20 11:17:41 238

原创 C++版本百鸡问题1045

#include "stdafx.h"#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ int n; while (cin>>n) { for (int x = 0; x <= 100; x++){ for (int y = 0; y <= 100-x; y++){

2017-02-19 13:21:48 504

原创 C++版本查找(找X问题)1052

#include "stdafx.h"#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ int buf[200]; int n; int i; while (cin >> n){ for (i = 0; i < n; i++){ cin >> buf[i]; } int

2017-02-19 11:47:52 444

原创 string::size_type类型

#include "stdafx.h"#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ string line; string::size_type i=0; while (getline(cin, line)){ if (line.size() > 10){ cout

2017-02-18 18:55:02 366

原创 string的empty和size操作

#include "stdafx.h"#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ string line; while (getline(cin, line)){ if (!line.empty()) cout << line << endl; } return

2017-02-18 18:31:36 805

原创 使用getline读取一整行

#include "stdafx.h"#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ string line; while (getline(cin, line)) cout << line; return 0;}输出结果为:

2017-02-18 18:15:16 881

原创 C++(定义和初始化string对象)

#include "stdafx.h"#include#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ string s1; string s2; string s3 = "hiya"; string s4(10, 'c'); string s5(s3 + s4); cout << s1 <

2017-02-18 17:49:15 4796

原创 算法导论第15章15.2-6

利用归纳法即可证明。当n为1时,不需要括号,当n=2时 恰好有1对括号。假设当n=k(2

2017-02-08 17:20:43 479

原创 算法导论第十五章15.2-4

算法导论第15章368页,当思考一个动态规划问题时,我们应该弄清楚所涉及的子问题与子问题的依赖关系,问题的子问题图准确的表达了这些信息。那么根据此图可以来回答题目15.2-4.输入链长度为n那么矩阵数目为n-1,所以子问题图一共包含n-1个定点,一共包含1+2+3+......+n-1=1/2(n^2-n)条边,这些边连接原问题顶点和比其更小的子问题的顶点

2017-02-08 17:07:03 1311 1

原创 算法导论第15章15.2-5

第九行 for 循环执行j-i次,即为l-1次,调用m[i,j] 2(l-1)次,加上外面两层循环一共1/3(n^3-n)

2017-02-08 16:47:43 1759

原创 算法导论第15章15.2-2

MATRIX-CHAIN-ORDER得到的表s中存储的数值就是子问题中的分割点k。MATRIX-CHAIN-MULTIPLY(A,s,i,j)          if i=j          return 0          else          k=s[i,j]         return (MATRIX-CHAIN-MUTIPLY(A,s,i,k)+MATR

2017-02-07 10:46:34 910

原创 算法导论第15章15.2-1

找了一段C实现的矩阵链乘法#include "stdafx.h"#include#include#define N 1000int m[N][N];  //m[i][j]表示从第i个矩阵乘到第j个矩阵所需的最小代价int s[N][N];  //s[i][j]表示最优值m[i][j]对应的分割点int p[N];     //p[]代表矩阵链void MATRIX_

2017-02-06 17:47:57 2586

原创 算法导论第15章习题15.1-4

定义全局变量k存储子函数计算最大收益时的变量i#include "stdafx.h"#include using namespace std;int k=0;int Max(int a, int b){return a>b ? a : b;}int MEMOIZED_CUT_ROD_AUX(int p[], int n, int r[],int &k){

2017-02-05 12:59:45 1396

寻找最长单词算法(最优版不论最长单词多长都能查找成功)

C语言写的查找输入的最长的单词,无论单词多长都能查找成功,最长的单词有多个也都能输出

2016-06-07

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除