使用Dev-C++查看vector数组中的变量值

可以通过调试的时候添加查看:比如说有一个长度为3的vector v,如果想要查看v[0]的值,就在添加查看中写 *(&v[0])

如果想要查看整个数组的值,就可以写*(&v[0])@3

@后面的数字表示想要查看的长度,这里vector的长度是3所以可以写3就能看到所有的值~

LeetCode 524. Longest Word in Dictionary through Deleting

Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.

Example 1:
Input:
s = “abpcplea”, d = [“ale”,”apple”,”monkey”,”plea”]

Output:
“apple”
Example 2:
Input:
s = “abpcplea”, d = [“a”,”b”,”c”]

Output:
“a”
Note:
All the strings in the input will only contain lower-case letters.
The size of the dictionary won’t exceed 1,000.
The length of all the strings in the input won’t exceed 1,000.

题目大意:给一个string s和一个string字典d,找字典中的某个string,寻找s的子串(满足可以通过删除s中某些元素后得到该string),寻找满足条件的字符串中最长的一个,如果有多个长度相等的就返回字典序中最小的那个,如果一个都没有满足条件的string,就返回一个空字符串~
分析:遍历字典中的某一个字符串,设当前字符串的下标为index,对于当前字符串d[index],使用两个指针i和j分别从头到尾遍历s和d[index],随着i指针的增加,如果j指针所指元素和i指针所指元素相同就向后移动一位,当i指针都指完的时候,j如果也指完了说明满足条件,当前d[index]是s的子串,如果当前d[index]的长度比保存的result字符串长度长,就更新result,或者一样长但是字典序排列中d[index]比result小,也要更新result,最后返回result~

 

LeetCode 530. Minimum Absolute Difference in BST

Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.

Example:

Input:

1
\
3
/
2

Output:
1

Explanation:
The minimum absolute difference is 1, which is the difference between 2 and 1 (or between 2 and 3).
Note: There are at least two nodes in this BST.

题目大意:给一棵二叉搜索树,结点的值都为非负,找到两个元素值之差的绝对值的最小值~
分析:二叉搜索树,用中序遍历后得到的结果是从小到大的元素,遍历这个中序遍历后的结果数组,就可以得到两个元素值之差的绝对值的最小值~

 

蓝桥杯 ADV-214 算法提高 3-3求圆面积表面积体积

问题描述
  接受用户输⼊的数值,输出以该值为半径的(1)圆面积,(2)球体表面积,(3)球体体积。pi 取值3.1415926536 ,结果保留10位小数,每一列占20个字符,左对齐。
样例输入
一个满足题目要求的输入范例。
例:
1
样例输出
与上面的样例输入对应的输出。
例:(第一行1是输入,第二行是输出)

数据规模和约定
  所有结果在double类型的表示范围内。

 

蓝桥杯 ADV-212 算法提高 3-1课后习题2

问题描述
  编写一个程序,接受用户输入的10个整数,输出它们的和。
输出格式
  要求用户的输出满足的格式。
  例:输出1行,包含一个整数,表示所有元素的和。
样例输入
1 2 3 4 5 6 7 8 9 10
样例输出
55
数据规模和约定
  输入数据中每一个数的范围。
  例:输入数<100000。

 

蓝桥杯 ADV-211 算法提高 2-2整数求和

基于例子3 ,写一个程序,实现整数求和:
样例输入
3 4
样例输出
7