`
wss71104307
  • 浏览: 219159 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
int a,b,c; int *p; a=100; c=10; p=&c; b=a/*p; printf("%d",b);   编译错误: 未结束的注释
/* 求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 ...
#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; } } } } } ...
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 ...
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 ...
#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 ...
#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 ...
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. - ...
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.
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) ...
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++] ...
<<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') ...
一个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  
将一个字符串中的字母替换为字母表中的下一个字母,保持大小写不变,非字母的字符不变,例如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] ...
看到好多面试问Servlet的生命周期问题的,找到个比较好的回答,贴在这里,以后研究。以下内容摘自<<精通 servlet>> 写道 Servlet容器(以前称Servelt引擎)实际上是执行servlet的软件。所有支持servlet的服务器包括一个servelt容器(集成的或通过插件。)术语支持java的服务器常指一个增强的servletHTTP服务器(即它包括一个用于运行servlet的 servlet容器) Servlet生命周期:以下是一个服务器调用servlet的过程。 1, 在服务器启动时,当servlet被客户首次请求或被配置好,这时由服务器加载serv ...
Global site tag (gtag.js) - Google Analytics