摘要: 1 class Solution{ 2 public: 3 double myPow(double x,int n){ 4 if(1==x || n==0) return 1; 5 if(n == 1) return x; 6 if (n < 0) { 7 n = -n; 8 x = 1/x; 9 阅读全文
posted @ 2020-05-28 13:18 糖糖_彭 阅读(435) 评论(0) 推荐(0) 编辑
摘要: 步骤: 1)先去除字符串收尾的空格 2)然后根据e划分指数和底数 3)判断指数和底数是否合法即可 1 class Solution { 2 public: 3 bool isNumber(string s) { 4 //首先去掉首尾的空格 5 int i = s.find_first_not_of( 阅读全文
posted @ 2020-05-28 12:57 糖糖_彭 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 实例:机器人运动范围 一:BFS算法 队列实现 当图或树根节点满足条件就入队,若子节点满足条件,子节点入队,根节点出队,重复操作。 在机器人运动中,计算满足条件的数量,BFS算法只需考虑向右(x+!,y)或向下(x,y+1) 1 class Solution {//广度优先遍历 2 public: 阅读全文
posted @ 2020-05-27 11:31 糖糖_彭 阅读(237) 评论(0) 推荐(0) 编辑
摘要: https://docs.nvidia.com/cuda/archive/9.0/index.html cuda9.0工具包 阅读全文
posted @ 2020-05-20 09:13 糖糖_彭 阅读(157) 评论(0) 推荐(0) 编辑
摘要: c++条款 num 1:尽量以const enum inline替换#define 1)对于单纯常量,最好以const对象或enums替换#defines 2)对于形似函数的宏,最好改用inline函数替换#define num 2:尽可能使用const 1)将某些东西声明为const可帮助编译器侦 阅读全文
posted @ 2020-05-20 08:39 糖糖_彭 阅读(396) 评论(0) 推荐(0) 编辑
摘要: 1 //哈希表查询与插入删除速率非常快速 2 #include<unordered_map> 3 #include<map> 4 #include<iostream> 5 6 using namespace std; 7 template<typename Key,typename Value> 8 阅读全文
posted @ 2020-05-14 12:09 糖糖_彭 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 一:get() //【例12-2】 用函数get和getline读取数据。 #include <iostream> using namespace std; int main() { char a,b,c,d; cin.get(a); cin.get(b); c = cin.get(); d = c 阅读全文
posted @ 2020-04-27 20:24 糖糖_彭 阅读(306) 评论(0) 推荐(0) 编辑
摘要: https://github.com/Light-City/CPlusPlusThings 阅读全文
posted @ 2020-04-27 10:54 糖糖_彭 阅读(375) 评论(0) 推荐(0) 编辑
摘要: /* 使用前向引用声明虽然可以解决一些问题,但它并不是万能的。需要注意的是, 尽管使用了前向引用声明,但是在提供一个完整的类声明之前,不能声明该类的对象, 也不能在内联成员函数中使用该类的对象。请看下面的程序段: */ //第一种 #include<iostream> class Fred; //前 阅读全文
posted @ 2020-04-27 10:52 糖糖_彭 阅读(617) 评论(0) 推荐(0) 编辑
摘要: 1:矢量或列表使用迭代器 for (auto pr = scores.begin();pr != scores.end();pr++) cout << *pr; 或 for (auto x : scores) cout << x <<endl; 2:迭代器类型 1)输入迭代器 单向迭代器,可以递增, 阅读全文
posted @ 2020-04-26 19:37 糖糖_彭 阅读(122) 评论(0) 推荐(0) 编辑