- 浏览: 225614 次
- 性别:
- 来自: 南京
-
最新评论
-
ranguisheng:
沙漏的问题貌似可以抽象为一个编程问题,(上7,下0)-(上4, ...
MicroStrategy的面经(from bbs.byr.. -
wss71104307:
米牛牛 写道谢谢!另外关于最后一段的证明、是否可以将【前i个元 ...
Reservoir Sampling -
米牛牛:
谢谢!另外关于最后一段的证明、是否可以将【前i个元素】改为【池 ...
Reservoir Sampling -
javaDevil:
引用self.parent.tb_show(t,a,g); ...
thickbox跨越frameset -
wangyazhen:
这样写似乎不大好,比普通的js要简洁,但是通用性还是差了点,建 ...
Jquery 表单验证
文章列表
int a,b,c;
int *p;
a=100;
c=10;
p=&c;
b=a/*p;
printf("%d",b);
编译错误: 未结束的注释
- 2008-11-02 18:17
- 浏览 908
- 评论(0)
/*
求2有序N长数组,第K大的数
*/
#include <stdio.h>
#include <iostream>
#include <assert.h>
#include <algorithm>
#define min(x,y) (x)<(y) ? (x) : (y)
#define max(x,y) (x)>(y) ? (x) : (y)
const int N = 4;
using namespace std;
//方法一 注意 第K大,还有2个边际
int FindKth(int A[], int B ...
- 2008-11-02 14:19
- 浏览 1368
- 评论(0)
#include <stdio.h>
void ShellSort(int A[], int n)
{
int gap;
for(gap=n/2; gap>0; gap/=2)
{
for(int i=gap; i<n; i++)
{
for(int j=i; j>=0; j-=gap)
{
if(A[j]<A[j-gap])
{
int temp;
temp=A[j];
A[j]=A[j-gap];
A[j-gap]=temp;
}
}
}
}
}
...
- 2008-10-29 21:14
- 浏览 1058
- 评论(0)
Let X
[1 .. n
]
and Y
[1 .. n
] be two arrays, each
containing n
numbers already in sorted order. Give an O
(lg n
)-time algorithm to find the
median of all 2n
elements in arrays X
and Y
.
#include <stdio.h>
#include <stdlib.h>
/*
*求2个已经排好序的同样为n大小的数组的中位数算法
*/
int FindMedian(int ...
- 2008-10-29 20:21
- 浏览 1324
- 评论(0)
CoutingSort
#include <stdio.h>
#include <stdlib.h>
void CountingSort(int A[], int B[], int k,int n)
{
int * C;
C=(int *)calloc(k,sizeof(int));
for(int i=0;i<n; i++)
{
C[A[i]]++;
}
for(i=1; i<k; i++)
{
C[i]+=C[i-1];
}
for(i=n-1; i>=0; --i)
{
B[C[A[i]]-1]=A[i ...
- 2008-10-29 11:16
- 浏览 970
- 评论(1)
#include <stdio.h>
#include <stdlib.h>
void swap(int & a,int & b)
{
int temp=a;
a=b;
b=temp;
}
int QuickSort_Partition(int A[],int p, int r)
{
//随机选值
int s_max=rand()%(r-p+1)+p;//随机数生产后要加上p
swap(A[s_max],A[r]);//随机数生成后注意交换
int max=A[r];
int i=p-1;
int j=p;
while(j ...
- 2008-10-28 20:50
- 浏览 940
- 评论(0)
#include <stdio.h>
int main(void) {
int a[]={1,2,3,4,5};
int * p=(int *)&a+1;
printf("*(a+1)=%d\n",*(a+1));
printf("*p=%d",*(p-1));-
}
输出为:
*(a+1)=2
*p=5
Explain:
a的类型为int [],&a的类型为 int(*)[],&a+1指向数组的下一行,p为int *,所以指向&a+1(a的第二行)的首地址,p-1 ...
- 2008-10-27 20:29
- 浏览 1076
- 评论(0)
1. //请教一个笔试题,:
2. public static void main(String[] args) {
3. // TODO Auto-generated method stub
4. int i= 0xFFFFFFFA;
5. int j=~i;
6. System.out.println(i);
7. System.out.println(j);
8. }
9. /*结果为什么是:
10. - ...
- 2008-10-25 12:10
- 浏览 995
- 评论(0)
reading <<The C Programming language>> of the English Version.
Though i just have read two chapters, i have found i learn a lot about C language.
Fighting.Stick to it.
- 2008-10-22 23:07
- 浏览 972
- 评论(1)
Write a alternate version of squeeze(s1,s2)
that deletes each characters in s1 that maths any character in string s2
#include <stdio.h>
/*字符串s1 中删除所有在s2里出现的字符*/
void squeeze(char s1[],char s2[])
{
int i,j,p;
for (i=0;s2[i];++i)//对S2中每个character,在S1中搜索一边
for (j=0;s1[j];++j)
...
- 2008-10-22 16:40
- 浏览 1773
- 评论(0)
reading the book of 《the C programing language》,write a program by myself about strcat
,but here is a mistake. I recode the program here in order to find the causation in future.
#include <stdio.h>
void myStrcat(char s[],char t[])
{
int i=0,j=0;
while(s[i] != '\0') i++;
while((s[i++] ...
- 2008-10-22 15:53
- 浏览 1214
- 评论(0)
<<The C programming language>> has an Exercise.
Convert a String of hexademical digits into a Int.
#include <stdio.h>
int hexaDecimalToDecimal(char s[])
{
if(s[0]!='0') return -1;
if(s[1]!='X' && s[1]!='x') return -1;
int i=2;
int sum=0;
while(s[i]!='\0')
...
- 2008-10-22 13:47
- 浏览 1145
- 评论(0)
一个7L瓶子,一个5L瓶子,怎么合成出6L的水 。
结果为 写道
7L瓶子 5L瓶子 倒满=> 7L 0L 7L ----倒5L--> 5L ==>倒掉 剩下0L 2L ----倒2L--> 2L 倒满=> 7L ----倒3L--> 5L ==>倒掉 剩下0L 4L ----倒4L--> 4L ==>倒掉 剩下0L 倒满=> 7L ----倒1L--> 5L 剩下6L
- 2008-10-22 08:57
- 浏览 837
- 评论(0)
将一个字符串中的字母替换为字母表中的下一个字母,保持大小写不变,非字母的字符不变,例如Mn.123Zxy-->No.123Ayz
分析:没什么难点,注意Z-->A,z-->a 就行了。
代码:
#include <stdio.h>
void charAddOne(char s[])
{
int i=0;
while(s[i]!='\0')
{
if(s[i]=='Z') s[i]='A';
else if(s[i]=='z') s[i]='a';
else if(s[i]>='A' && s[i] ...
- 2008-10-22 08:42
- 浏览 934
- 评论(0)
看到好多面试问Servlet的生命周期问题的,找到个比较好的回答,贴在这里,以后研究。以下内容摘自<<精通 servlet>> 写道
Servlet容器(以前称Servelt引擎)实际上是执行servlet的软件。所有支持servlet的服务器包括一个servelt容器(集成的或通过插件。)术语支持java的服务器常指一个增强的servletHTTP服务器(即它包括一个用于运行servlet的 servlet容器) Servlet生命周期:以下是一个服务器调用servlet的过程。
1, 在服务器启动时,当servlet被客户首次请求或被配置好,这时由服务器加载serv ...
- 2008-10-21 22:37
- 浏览 923
- 评论(0)