摘要:
转载: 一、好首先看看sizeof和strlen在MSDN上的定义:首先看一MSDN上如何对sizeof进行定义的:sizeof Operatorsizeof expressionThe sizeof keyword gives the amount of storage, in bytes, associated with a variable or a type (including aggregate types). This keyword returns a value of type size_t.The expression is either an identifier or 阅读全文
摘要:
题目:已知一个数组a[N],构造一个数组b[N],构造规则:b[i]=a[0]*a[1]*a[2]...a[N]/a[i]; 要求: 1、不可以使用除法; 2、时间复杂度为O(n),空间复杂度为S(0); 3、除遍历使用的变量外,不可以使用其它变量;从前往后扫一遍,然后从后往前再扫一遍。也就是说,线性时间构造两个新数组,B[i]=A[1]*A[2]*...*A[i],A[i]=A[n]*A[n-1]*...*A[i]。于是,B[i]=B[i-1]*A[i+1]。i=N和0特殊处理#include<stdio.h>
int main()
{ int i, a[5]={... 阅读全文
摘要:
时间复杂度nlogn,空间复杂度nlmin[k]表示前i个元素中长度为k的所有递增子序列的最后一个元素的最小值。#include<stdio.h>#define N 10
int lmin[10];
//找到==或者大于e的第一个数的位置 int bsearch(int a[],int p,int r,int e)
{ int m; while(p<=r) { m=(p+r)>>1; if(a[m]>e)r=m-1; else if(a[m]<e)p=m+1; else return m; } return p;//返回大于的第一个数位置 //retu 阅读全文