摘要: #include <iostream>#include <string.h>using namespace std;/*void change(char ch){ if(ch>='1' && ch<'10') { }}int main(){ char str[] = "12AEE"; for(int i=0;i<strlen(str);i++) { char ch = str[i]; change(ch); } return 0;}void fun1(int n){ switch(n) 阅读全文
posted @ 2012-09-22 14:42 SA高处不胜寒 阅读(314) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <sstream>#include <stdio.h>#include <math.h>using namespace std;char ch[20];int cnt = 0;int split_int(int num){ int temp1,temp2; char ch1[6]; int i=0; while(num%10) { temp1 = num%10; ch1[i] = temp1+'0'; i++; num=num/10; } for(int k=i-1;k> 阅读全文
posted @ 2012-09-12 19:35 SA高处不胜寒 阅读(4860) 评论(0) 推荐(0) 编辑
摘要: 编写函数,统计在某段英文文本完整句子的数目,文本只包括大小写英文字母,空格,点号(.),逗号(,),完整句子必须包含至少一个字母并以一个点号结束。实现了一下,不知道可有漏洞#include <iostream>#include <fstream>using namespace std;#define maxsize 1024int get_sentence_num(){ fstream file1("I:\\origin.txt"); char ch,des_ch[maxsize]; int flag = 0, i = 0,result=0; whi 阅读全文
posted @ 2012-09-11 22:10 SA高处不胜寒 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 我发现有个公司面试的时候问了对TCP协议比较细节的地方,那就写一下帮助自己加深理解和记忆。在开始说TIME_WAIT状态之前,要知道TCP协议是如何关闭连接的。很多人对TCP协议的三次握手都很熟悉(不知道的可以参考我以前的帖子),因为学校的垃圾考试都爱考三次握手,但是很多知道三次握手的人都对TCP协议是如何关闭连接不了解。不说废话了,TCP关闭连接过程如下图,寡人用photoshop画的,凑合看一下:为了方便描述,我给这个TCP连接的一端起名为Client,给另外一端起名为Server。上图描述的是Client主动关闭的过程,FTP协议中就这样的。如果要描述Server主动关闭的过程,只要交换 阅读全文
posted @ 2012-09-11 20:40 SA高处不胜寒 阅读(695) 评论(0) 推荐(0) 编辑
摘要: 下面所指的signal都是指以前的older signal函数,现在大多系统都用sigaction重新实现了signal函数1、signal在调用handler之前先把信号的handler指针恢复;sigaction调用之后不会恢复handler指针,直到再次调用sigaction修改handler指针。:这样,(1)signal就会丢失信号,而且不能处理重复的信号,而sigaction就可以。因为signal在得到信号和调用handler之间有个时间把handler恢复了,这样再次接收到此信号就会执行默认的handler。(虽然有些调用,在handler的以开头再次置handler,这样只能 阅读全文
posted @ 2012-09-10 18:54 SA高处不胜寒 阅读(8148) 评论(2) 推荐(1) 编辑
摘要: #include <iostream>using namespace std;class a{public:virtual void aa(){};};class b:public a{public:virtual void aa(){};virtual void bb(){};};class c: public b{public:virtual void aa(){};virtual void cc(){};};int main(){cout<<sizeof(a)<<endl;cout<<sizeof(b)<<endl;cout&l 阅读全文
posted @ 2012-09-10 15:30 SA高处不胜寒 阅读(497) 评论(0) 推荐(0) 编辑
摘要: 首先我们来看一段代码#include <iostream>using namespace std;class example{public: example() { output(); } virtual void output() { cout<<"The construct can call virtual function!"<<endl; }};class exam:public example{ public: virtual void output() { cout<<"The second one!&q 阅读全文
posted @ 2012-09-10 15:24 SA高处不胜寒 阅读(1814) 评论(0) 推荐(0) 编辑
摘要: 在linux下stdout是行函数,也就是在遇到\n前都将数据存储在buffer中,而stderr则是不缓冲的,例如:int main(){fprintf(stdout,"Hello ");fprintf(stderr,"World!");return 0; } 在linux下其输出为World!Hello 而在windows下其输出Hello World!也就是说 在window下stdout和stderr一样都是不缓存的。 阅读全文
posted @ 2012-09-08 15:23 SA高处不胜寒 阅读(766) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;void DecToBin(unsigned int dec,char ch[] ){ int i = 31; while(i >= 0) { int temp = dec; temp = temp >> i; ch[32-i-1] = (temp & 1)+'0'; i--; }}int main(){ char ch1[33]; DecToBin(12,ch1); ch1[32] = '\0'; cout<<ch1<<e 阅读全文
posted @ 2012-08-22 22:07 SA高处不胜寒 阅读(1810) 评论(0) 推荐(0) 编辑
摘要: 今天好友微软笔试,把题目发给我看了,不过由于英语不好,看了很久才懂,唉,题目如下:Here goes the question: > > Write a method that find the int that has the most occurred number 1 in the input int array, and write test cases that you can think.> > Please return me the answer no later than 20:20.这上面的1当时理解为整形的二进制中的1,则代码如下:#include 阅读全文
posted @ 2012-08-22 21:42 SA高处不胜寒 阅读(167) 评论(0) 推荐(0) 编辑