1.冒泡排序 从小到大 function bubbing(){ var oldList = [1,6,32,7,8,245,2345,25,4,245245,14312]; for(var i = 0; i oldList[j+1]) { var temp = oldL...
分类:
编程语言 时间:
2015-07-25 14:58:55
阅读次数:
144
//用栈实现
class Solution {
public:
int largestRectangleArea(vector& height) {
stack index;
vector high=height;
int result=0;
int temp;
high.push_back(0);
for(int i=0;...
分类:
其他好文 时间:
2015-07-25 07:10:35
阅读次数:
98
直接插入排序是最简单的排序算法,基本思想是每次将一个带排序的记录,按其关键字大小插入到前面已排序好的子序列中,直到全部数据完成。其相应的C代码实现如下:#include "stdio.h"void InsertSort(int a[], int n) //直接插入排序{ int i,j,temp=0...
分类:
编程语言 时间:
2015-07-24 23:53:37
阅读次数:
135
题目链接:点击打开链接
题目大意:给出你n个数,要求把这n个数排列成有序的(由小到大),每次可以交换两个数,花费是这两个数的和,现在求最小的花费
置换群的入门
求出每一个轮换的圈,对于每一个轮换中,只有在自身内交换就能完成有序,而不需要和其它轮换交叉。
一个轮换的最小值temp,轮换中有num个数,轮换的总和是sum,整个序列的最小值min1
让一个轮换花费最少有两种可能
1、轮换自身...
分类:
其他好文 时间:
2015-07-24 22:42:10
阅读次数:
148
def add(temp): temp="aaa"def add2(temp): temp[0]="aaa"a=11print aadd(a)print ab=[1,2]print b[0]add2(b)print b[0]结果:11112aaa因此要想改变的话 必须用字典或者其他类似的
分类:
编程语言 时间:
2015-07-24 22:10:24
阅读次数:
130
求模(mod):直接在草稿纸上用小学方法算除法就能看出来 1 #include 2 #include 3 char m[1010]; 4 int main(){int n,temp; 5 while(~scanf("%s %d",m,&n)){temp=0; 6 for(in...
分类:
其他好文 时间:
2015-07-24 20:17:16
阅读次数:
91
1 2 3 4 5 6 7 8 9 10需要得到一个数组 new Array=(1,2,3,4,5,6,7,8,9,10)var arr = document.getElementsByTagName('li'),temp = [];fo...
分类:
编程语言 时间:
2015-07-23 09:26:23
阅读次数:
277
(1) 预处理出所有数的乘积,然后每次去除nums[i],可以得到正确的答案数组,但是题目中明确写明without division .,不可行。
(2) 预处理出前n项的乘积,放到temp数组中,然后倒着遍历,为了节约空间,我们使用一个Cur变量记录当前后面的乘积。
class Solution {
public:
vector productExceptSelf(vector& n...
分类:
其他好文 时间:
2015-07-23 00:47:28
阅读次数:
95
随机数获取arc4random()这个全局函数会生成9位数的随机整数1,下面是使用arc4random函数求一个1~100的随机数(包括1和100)1 var temp:Int = Int(arc4random()%100)+12,下面是使用arc4random_uniform函数求一个1~100的...
分类:
移动开发 时间:
2015-07-23 00:33:12
阅读次数:
227
正常是交换两个变量的值应该使用中间变量:function swap($a, $b){$temp = $a;$a = $b;$b = $temp;}1.这个方法很容易想到,但是只限于交换数值类型的变量:function swap (&$a,&$b){$a = $a+$b;$b = $a-$b;$a =...
分类:
Web程序 时间:
2015-07-22 17:51:22
阅读次数:
116