当前位置:   article > 正文

C++代码之 常用算法汇总_c++ 常用算法 代码

c++ 常用算法 代码

算法–基础

  1. 排序–插入排序–直接插入排序 代码
  2. 排序–插入排序–折半插入排序 代码
  3. 排序–插入排序–两路插入排序 代码
  4. 排序–插入排序–希尔排序 代码
  5. 排序–交换排序–冒泡排序 代码
  6. 排序–交换排序–快速排序 代码
  7. 排序–选择排序–简单选择排序 代码
  8. 排序–选择排序–堆排序 代码

算法–面试题

2015-08-20 RGB Problem, IGT –字符串类
一个字符串,里面只有三种字符RGB 所有的R都在G的前面,所有的G都在B的前面, 将给定字符串按照此规律排序。
要求不允许用辅助空间,复杂度控制在O(N),遍历一遍。
解法 1 代码


2015-08-21 longest common sub–string, IGT
Please implement a function to find the longest common sub–string of two given string.
For example:
string a: abcdefg12345
string b: cdef234
longest common sub–string:cdef
解法 1 代码


2015-08-21 Expression AmazonTest2012Q1

Question: From AmazonTest2012Q1
Given an array with positive integers and another integer.
for example{7 2 4} 9, you are required to generate an equation,
by inserting operator add (“+”) and minus (“-“) among the array.
The left side of equation are consist of the array and the right
side of equation is the integer. here the result is 7-2+4=9
Rules:
Don’t include any space in the generated equation.
In case there is no way to create the equation, please output “Invalid”.
For example {1 1} 10, output is “Invalid”
The length of the integer array is from 1 to 15( include 1 and 15). If
the length is 1, for example the input {7} 7, the output is 7=7
There is no operator “+” or “-” in front of the first number:
Don’t change the order of the numbers. For example: {7 2 4} 9. 7-2+4=9 is
correct answer, 4-2+7=9 is wrong answer.
There could be multiple input, meaning your function could be called
multiple times. Do remember print a new line after the call.

[解法 1 代码] Working


2015-08-25 字符串中包含唯一字符的最长子串
Question: Given a string, find the longest sub sequence
which contains only unique characters.
解法 1 代码

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/278128
推荐阅读
相关标签
  

闽ICP备14008679号