- 博客(24)
- 收藏
- 关注
原创 Linux的g++编译报错: undefined reference to `pthread_create‘ collect2: error: ld returned 1 exit status
Multithread practice#include <iostream>#include <thread>void function1(){ for(int i =0; i< 200; i++){ std::cout << "+"; }}void function2(){ for(int i= 0; i< 200; i++){ std::cout << "-";
2021-10-28 10:51:39
845
1
原创 将本地文件推送到github (重点:合并分支到主branch上)
首先将github 仓库地址clone 到local$ git clone https://github.com/xxx/testRepository.git进入local仓库$ cd testRepository假如把测试文件 test.cpp 推送到github的 远程testRepository 仓库中;$ touch test.cpp // 新建一个待推送的测试文件在此,有两种情况可以参考:直接在主branch上操作;在分支上操作,最后merge到主branch.
2021-05-19 00:56:51
511
原创 Cmake 报错
把在另一台电脑上写好的习题,移植到笔记本上运行,会出现cmake编译报错。根据 这里的错误显示,原先用的版本是13.3, 笔记本上显示最少要用13.6,所以把cmake要求的最低版本改成13.3,然后点击右上角reload changes:现在可正常运行。...
2021-05-01 09:39:30
1113
原创 Accelerate c++chapter5__ exercice5.2关于怎么导入使用txt文件
1、前言CLion 写C++ 代码时候,需要读取本目录下txt文件,但是又不想使用绝对路径(ps:Mac 绝对路径真是太长了),那么就是得使用相对路径了。可以做如下设置,就可以打开文件并读取了题目5-2有需要比较运行效率,需要导入txt文件。怎么让这个txt文件被调用呢?2、设置CLion 在Edit Configurations, 选择对应的项目, 然后在Working dictionary里选择相应的程序目录,经测试成功。1)先添加一个目录TestFile,2) Working dic
2021-01-02 02:09:24
288
1
原创 2-2 Problem Formulation (ii) - Abstraction
例1:8个状态如图所示,最后两个就是goal state.例2:例3:八皇后
2020-09-14 08:14:00
289
原创 人工智慧:搜索方法与逻辑推论 (Artificial Intelligence - Search & Logic) week2
那search基本上分成:uninformed,和 informed search. 两者差别在于我们对于基础问题的 knowledge 有多少。两种search技巧:tree and graph search两者区别就是会不会侦测state有无重复。前者不会,后者会,重复的就不再去搜索。1.拿到一些percept感知,通过sensor感知一些事情后,update它目前对世界的预估。就是他目前的state。3.根据目前对世界美好的猜测,state,去构建一个目标goal.4.有.
2020-09-14 07:42:59
391
原创 160. Intersection of Two Linked Lists
// idea: a+allcommon+b = b + allcommon+a;//a represents the len before the intersect pos in list A;//b represents the len before the intersect pos in list B;//take the lists as a whole, so the tota...
2020-04-17 23:13:05
173
原创 java语句,return;break;continue;
return:return;是只能直接回到上一层继续往下执行,不会直接导致整个程序的停止执行。break:break;只在switch语句体和循环体应用,一个break;语句能退出一个switch语句体或循环体,不会执行循环体或switch语句体余下的语句,不能连续退出多个switch语句体或循环体。continue:自己目前只在循环体应用,continue;跳过本次循环体中余下尚未执行的语...
2020-04-06 05:11:04
3141
原创 Leetcode 189. Rotate Array
Given an array, rotate the array to the right by k steps, where k is non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the right: [7,1,...
2020-03-28 06:02:04
175
原创 一个简单的突发奇想求众数,LeetCode169. Majority Element
从摩尔投票思想出发:因为题目众数是出现次数超过一半,所以只可能有一个数字出现次数超过一半,就给一个变量num和count;遍历nums:count为0时,重新赋值count不为0时,判断,int a = num==nums[i] ? count++: count–class Solution { public int majorityElement(int[] nums) {...
2020-03-27 00:54:32
133
转载 特别好用的二分查找法模板(Python 代码、Java 代码)
https://www.liwei.party/2019/06/18/leetcode-solution-new/search-insert-position/
2020-03-12 07:08:01
196
原创 27. Remove Element
Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array...
2020-03-12 05:35:56
123
原创 2. array--删除排序数组中的重复项
class Solution { public int removeDuplicates(int[] nums) { int n= nums.length; if (n == 0) return 0; int distinc = 0;//(distinct)不同元素个数,初始为0 for (int i=0; i<n-1;...
2020-03-10 11:58:31
235
原创 1.Two Sum
//import the HashMap,Map to avoid the compile error//import java.util.Map;//import java.util.HashMap;public class Solution{ public int[] twoSum(int[]num, int target){ //twoSum方法 //用hashtable,建...
2020-03-09 11:48:54
152
原创 IntelliJ IDEA 中 右键运行时没有run
public class CustomerTest { public static void main(~~String[] args~~ ){ //创建Customer对象 Customer c1 = new Customer(); c1.name = "zhangsan"; //c1购物 c1.shop...
2020-02-25 07:55:33
2118
3
原创 python学习笔记chap10 debug
while 1: try: x = int(**raw_**input("Input a number:")) y = int(r**aw_**input("Input a number:")) z=x/y except **ValueError, ev**: print "That is no valid nu...
2020-02-11 04:14:32
212
原创 python学习笔记--chap10报错纠正
def inputAge(): age = input("Input your age:") if (age>100 or age<18): raise ’BadNumberError’, ’out of range’ return ageTypeError: ‘>’ not supported ...
2020-02-11 03:58:14
209
原创 python3中haskey()出现的报错
在《Python学习笔记》中第8.4节 暗示例子中:if previous.has_key(n):出现报错AttributeError: ‘dict’ object has no attribute ‘has_key’在Python3中,可以用一个比较简单的方式代替haskey(),使之可以运行。将 if previous.has_key(n):改成if n in previou...
2020-01-29 02:59:38
2943
原创 Python学习笔记: 7.7 分割范围 报错 for python3
numBuckets = 8buckets = [0] * numBucketsbucketWidth = 1.0 / numBucketsfor i in range(numBuckets):low = i * bucketWidthhigh = low + bucketWidthbuckets[i] = inBucket(list, low, high)print buckets...
2020-01-28 01:41:21
185
原创 Python中出现name 'raw_input' is not defined
❌NameError: name ‘raw_input’ is not defined ❌按照课本练习时,出现这个错误提示首先以为是没有调入相应的库查资料发现不是:2.x版本的输入函数为raw_input,在高级版本环境下就会报错如开头,该函数未定义。在3.x版本中用input()代替raw_input()。就可以解决这个问题。...
2020-01-21 11:44:55
849
原创 C语言中的字符(char)
字符串,它是多个字符的集合,例如 “abc123”、“123\141\142\143”;当然也可以只包含一个字符,例如 “a”、“1”、"\63"。不过为了使用方便,我们可以用 char 类型来专门表示一个字符,例如:char a=‘1’;char b=’$’;char c=‘X’;char d=’ ‘; // 空格也是一个字符char e=’\63’; //也可以使用转义字符的形...
2019-10-22 10:50:27
3749
原创 算法图解-1算法简介
第1章 算法简介 第一种查找算法——二分查找。 学习如何谈论算法的运行时间——大O表示法。 了解一种常用的算法设计方法——递归。1. 二分查找[1] 二分查找算法,必须针对的是有序的元素列表。[2]一般,对于n个元素的列表,二分查找最多需要log2(n)步, 简单查找(线性查找)则需要n步。C++编写执行二分查找:#include "iostream"using na...
2019-09-07 00:14:33
160
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅