自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(85)
  • 收藏
  • 关注

原创 算法 字符串与数组(2)

一个含有标点符号,数字,单词的字符串,将其中的单词反转bool isPunctationOrSpace(char *character)//判断标点符号或空格{ return *character == ' ' || *character == ',' || *character == '.';}bool isNumber(char *character)//判断数字{ retur...

2019-09-10 18:40:37 123

原创 算法:字符串数组问题

算法:字符串数组问题主要工具:hash table在长度为n的母串中匹配长度为m的子串Brute-force算法:(暴力求解)顺序遍历母串,将每个字符作为匹配字符,判断是否匹配子串。时间复杂度O(m*n)char * Strstr(const char *str, const char * target){ if (! *target) return str;...

2019-09-09 22:31:30 431

原创 C++面试题(上)

C++面试题(上)1.链表和顺序表的优缺点以及使用场景1)顺序表存储原理:顺序表存储是将数据元素放到一块连续的内存存储空间,存取效率高,速度快。但是不可以动态增加长度优点:存取速度高效,通过下标来直接存储,访问速度快,通过下标访问缺点:a.插入和删除比较慢,b.不可以增长长度比如:插入或者删除一个元素时,整个表需要遍历或移动元素来重新排一次顺序  2)链表存储原理:链表存储是在程序...

2019-09-03 12:07:36 279

原创 每日一题3.21.1

每日一题3.21.1题目描述:完全数问题代码实现:#include <iostream>#include <vector>using namespace std;int count(int n){ int sum = 0; for (int i = 1; i < n; i++) { if (n%i == 0) sum += i; ...

2019-08-16 23:34:23 144

原创 每日一题4.19.2

每日一题4.19.2Emacs计算器代码实现:#include<iostream>#include<vector>#include<string>#include<stack>using namespace std;int main(){ int n; int a, b, ret; while (cin >> ...

2019-08-16 23:34:09 95

原创 每日一题4.19.1

每日一题4.19.1五子棋自己写的代码没通过参考答案:

2019-04-25 15:06:42 139

原创 每日一题4.18.2

每日一题4.18.2最长上升子序列代码实现:#include<iostream>#include<algorithm>#include<vector>using namespace std;int main(){ int n; while (cin >> n) { vector<int> arr(n,0);...

2019-04-25 15:00:57 151

原创 每日一题4.18.1

每日一题4.18.1发邮件解题思路: 当n个编号元素放在n个编号位置,元素编号与位置编号各不对应的方法数用D(n)表示,那么D(n-1)就表示n-1个 编号元素放在n-1个编号位置,各不对应的方法数,其它类推. 第一步,把第n个元素放在一个位置,比如位置k,一共有n-1种方法; 第二步,放编号为k的元素,这时有两种情况:⑴把它放到位置n,那么,对于剩下的n-1个元素,由于第k个元素 放到了位...

2019-04-25 14:54:56 113

原创 每日一题4.17.2

每日一题4.17.2最长公共子序列解题思路:

2019-04-25 14:50:08 99

原创 每日一题4.17.1

每日一题4.17.1字符串计数参考答案:

2019-04-25 14:47:39 114

原创 每日一题4.16.2

每日一题4.16.2蘑菇阵解题思路: 使用动态规划,记录蘑菇,分别记录起点的概率和跳过起点的概率,边界处理,遇到蘑菇,将概率置为0** 代码实现:**#include<iostream>#include<vector>#include<algorithm>#include<iomanip>using namespace std;...

2019-04-25 14:43:10 155

原创 每日一题4.16.1

每日一题4.16.1红与黑代码实现:#include<iostream>#include<vector>#include<queue>#include<string>using namespace std;int dest[4][2] = { 1, 0, 0, 1, 0, -1, -1, 0 };struct node{ in...

2019-04-25 14:37:22 125

原创 每日一题4.15.2

每日一题4.15.2mkdir代码实现:#include<iostream>#include<string>#include<vector>#include<algorithm>using namespace std;int main(){ int n; while (cin >> n) { vector...

2019-04-25 14:27:30 141

原创 每日一题4.15.1

每日一题4.15.1数据库连接池解题思路: 使用一个set来做,如果某个记录是connect,就加到set中去,如果是disconnect,就把set中对应的值删 除掉。在加进去的过程中,不断判断set元素的最大个数,最终返回这个最大个数即可。代码实现:#include<string>#include<set>using namespace std;int...

2019-04-25 14:22:51 126

原创 每日一题4.12.1

每日一题4.12.1年会抽奖** 参考答案:**

2019-04-25 14:00:43 118

原创 每日一题4.10.2

每日一题4.10.2解题思路: 斐波那契数列问题,注意数据类型为long long类型代码实现:#include <iostream>#include <cstdio>using namespace std;int main(){ long long n[95] = { 1, 2 }; for (int i = 2; i < 95; i++) {...

2019-04-15 00:38:24 122

原创 每日一题4.10.1

每日一题4.10.1收件人列表解题思路: 输入字符串,判断内部是否有空格或逗号,用双引号包含代码实现:#include <iostream>#include <string>#include <cstdio>using namespace std;int main(){ int n; while (cin >> n) {...

2019-04-15 00:32:54 107

原创 每日一题4.9.2

每日一题4.9.2客似云来解题思路: 典型的斐波那契数列问题代码实现:#define _CRT_SECURE_NO_WARNINGS 1#include <iostream>#include <stdio.h>#include <cstdio>using namespace std;int main(){ long long data[...

2019-04-15 00:06:41 110

原创 每日一题4.9.1

每日一题4.9.1剪花布条解题思路: 长字符串中寻找子串的问题,尝试用过哈希,发现不行,用find在字符串中查找代码实现:#include <iostream>#include <string>using namespace std;int main(){ string str1, str2; while (cin>>str1>&...

2019-04-14 23:46:24 140

原创 每日一题4.8.2

每日一题4.8.2斐波那契凤尾解题思路: 计算斐波那契数列,注意输出的位数参考答案:

2019-04-14 23:33:29 115

原创 每日一题4.8.1

每日一题4.8.1淘宝网店解题思路: 一道过程复杂,原理简单的题,我分为了三种情况,两个日期在同一年内;两个日期在相邻的两年内;两个日期相差两年以上,分别计算,还要判断月份是否为素数,该年是否为闰年,用一个二维数组存储平年与闰年每月的天数,最后计算总收益代码实现:#include <iostream>#include <math.h>using namesp...

2019-04-14 23:27:17 107

原创 每日一题4.7.2

每日一题4.7.2分解因数解题思路: 从最小因子2到最大因子数字的平方根,依次遍历输出即可代码实现:#include <iostream>#include <math.h>using namespace std;int main(){ unsigned int n; while (cin >> n) { printf("%d =",...

2019-04-14 23:13:04 84

原创 每日一题4.7.1

每日一题4.7.1美国节日解题思路: 解法不难,过程比较复杂,建立一个二维数组,分别存放平年和闰年时每月的天数,需要一个判断闰年的函数,给定一个基础年份2000年,查一下日历2000年的1月1日是星期几,然后分别计算每一个纪念日所在的日期,如果是元旦,国庆,圣诞节这样的固定日期,就直接输出。代码实现:include <iostream>#include <cstdi...

2019-04-14 22:57:18 183

原创 每日一题4.6.2

每日一题4.6.2因子个数解题思路: 从数字的最小因子2到最大因子(数字的平方根)开始判断,是否能够取余,可以则循环到不能取余为止,因字数+1,最后得到的数字不为1,则增加自身因子数+1代码实现:#include <iostream>#include <math.h>using namespace std;int main(){ int n,i,j;...

2019-04-14 22:38:25 113

原创 每日一题4.6.1

每日一题4.6.1密码解析解题思路: 密码中大写字母-5得到密文,如果-5变为小写字母了,则需要加上26代码实现:#define _CRT_SECURE_NO_WARNINGS 1#include <iostream>#include <stdio.h>#include <cstdio>#include <string>us...

2019-04-14 22:13:17 163

原创 每日一题4.5.2

每日一题4.5.2有假币解题思路: 类似折半查找法,判断一次最多能从3个硬币中找出假币。所以将n个硬币每次分为三组,判断一次找出假币所在的一组,继续分为3组,直到最后剩下3个或以下的硬币数参考答案:...

2019-04-05 15:21:51 209

原创 每日一题4.5.1

每日一题4.5.1求正整数组的最小不可组成和原谅题目没看懂,没写出来参考答案及解题思路:

2019-04-05 15:16:13 392

原创 每日一题4.4.2

每日一题4.4.2猴子分桃解题思路: 因为每次分成5份后总会多出一个给老猴子,所以在总数x上加4个使得每次猴子能刚好分够5份,分一次,剩下的桃子数等于(x+4)*4/5个,之后每分一次,都剩下上次的桃子*4/5个,最后老猴子得到的桃子数为(x+4)*(4/5)^n+n-4个(每分一次给老猴子一个,再减去总数多给的4个)参考答案:...

2019-04-05 15:12:33 408

原创 每日一题4.4.1

每日一题4.4.1奇数位上都是奇数或偶数位上都是偶数自己写的总是通不过case参考答案:

2019-04-05 15:01:47 188

原创 每日一题4.3

每日一题4.3三角形解题思路: 小学数学题,两边之和大于第三边,两边之差小于第三边就可组成三角形代码实现:#include<iostream>using namespace std;int Triangle(double a, double b, double c){ if (a + b - c > 0 && a - b - c < 0 &...

2019-04-05 14:58:41 201

原创 每日一题4.2.2

每日一题4.2.2数根参考答案注意: 用字符串接收,输入的数字可能有几十位上百位

2019-04-05 14:53:59 98

原创 每日一题4.2.1

每日一题4.2.1星际密码参考答案

2019-04-05 14:24:09 109

原创 每日一题4.1.2

每日一题4.1.2快到碗里来解题思路: 只需要比较周长和身长就好容易踩坑: 半径和身长不能设为int型!!! 要设为double型!!!代码实现:#include <iostream>using namespace std;int Cat(double c,double r){ if ((3.14 * 2 * r) > c) return 0; else...

2019-04-02 21:42:06 109

原创 每日一题4.1

每日一题4.1变态跳台阶代码实现:#include <iostream>using namespace std;class Solution {public: int jumpFloorII(int number) { if (number <= 0) return 0; if (1 == number) return 1; return ...

2019-04-02 21:37:16 209

原创 每日一题3.30.2

每日一题3.30.2代码实现:#define _CRT_SECURE_NO_WARNINGS 1#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int map[10][10];int vis[10][10];int n, m;int he...

2019-04-02 21:31:05 148

原创 每日一题3.30.1

每日一题3.30.1年终奖参考答案:

2019-04-02 20:55:05 140

原创 每日一题3.29.2

每日一题3.29.2计算字符串的距离参考答案:

2019-04-02 20:50:54 160

原创 每日一题3.29.1

每日一题3.29.1微信红包代码实现:#include <iostream>#include <map>#include <vector>using namespace std;class Gift {public: int getValue(vector<int> gifts, int n) { // write code ...

2019-04-02 20:46:14 145

原创 每日一题3.28

每日一题3.28.1今天的编程题答案和做的题对不上号,很尴尬只好把答案直接搬上来了参考答案:第二题 找出字符串中第一个只出现一次的字符

2019-04-02 20:38:59 110

原创 每日一题3.27.2

每日一题3.27.2MP3光标位置解题思路: 当歌曲数小于4时,只有一页,所以只需考虑光标当前的特殊位置只有第一位和最后一位,第一位向上操作光标指向最后一行,最后一行向下光标指向第一行当歌曲数大于4时,就要考虑翻页问题,多设置一个变量now用来表示光标在当前页面上的位置代码实现:#include <iostream>#include <string>usi...

2019-04-02 20:33:05 125

空空如也

空空如也

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

TA关注的人

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