这就是我
最新公告
站点日历
最新日志
最新回复
最新留言
日志搜索
友情链接
mop
其他信息
· [爱科技] C++描述的数据结构(代码)---链表 -|2006-11-06|By:yingwang294
链表的cpp模板实现:template <class T> class ChainNode { friend Chain<T>; private: T data; ChainNode<T> *link; }; template<class T> class Chain { public: Chain(){first=0;} ~Chain(); bool IsEmpty() const{return first==0;} int Length() const; bool Find(int k,T& x)const; int Search(const T&x) const; Chain<T>& Delete(int k,T& x); Chain<T&g……
[阅读全文 (673) | (已有条评论) ]
· [爱科技] C++描述的数据结构(代码)---线性表 -|2006-11-06|By:yingwang294
线性表的cpp模板实现: template <class T> class LinearList { public: LinearList(int MaxListSize=10); ~LinearList(){delete [] element;} bool IsEmpty() const{return length==0;} int Length() const{return length;} bool Find(int k,T& x)const; int Search(const T& x)const; LinearList<T>& Delete(int k,T&x); LinearList<T>& Insert(int k,const T&a……
[阅读全文 (468) | (已有条评论) ]
· [爱科技] 再来两道考题 -|2006-11-03|By:yingwang294
1.via的考题一道 这个程序设计的思想是这样的: 为了测试32位机上的浮点数的运算精度,作如下考虑: 当1.5 == 1时(二进制1.1==1)精度为1个小数位 当1.25 == 1时(二进制1.01==1)精度为2个小数位 继续判断测试,直到两者相等,从而得到精度。 所以程序代码如下: int main() { int nCount; float number1,number2; nCount = 0; number1 = 1.0; number2 = 1.0 while( number1 + number2 != number1 ){ nCount++; number2 /= 2.0; } &……
[阅读全文 (396) | (已有条评论) ]
· [爱科技] 几道简单的华为考题 -|2006-11-01|By:yingwang294
a.char str[]="hello"; char *p=str; 32位机32位编译器,sizeof(str)= 6 sizeof(p)=4b.void getmemory(char **p,int num) { *p=(char *)malloc(num); } void main(void) { char *str=NULL; getmemory(&str,100); strcpy(str,"hello"); printf(str); }运行结果为:helloc.int arr[]={6,7,8,9,10}; void main() { int *ptr=arr; *(ptr++)+=123; printf("%d,%d\n",*ptr,*(++ptr)); }运行结果为8,8……
[阅读全文 (669) | (已有条评论) ]
· [爱科技] 结构体大小问题 -|2006-11-01|By:yingwang294
a.问struct a{ int a; int b; int c;};有多大。。这个比较简单,用sizeof(),vc(32位编译器)测得12个字节,用tc测得6个字节。。。b.问struct a{int a:3;int b:4;int c:6;};有多大,当定义一个变量x时,struct a x;x.a=1;x.b=2;x.c=3;用小端表示应为如何?3+4+6=13<32位,补齐,按32位,即可得大小为4个字节。。。小端表示应为:10010001 00000001 00000000 00000000后面两个字节为全0,前两个字节,第一个字节的低3位001即为x.a=1;接着4位,0010即为x.b=2;接着最高一位1和第二个字节的低5位,00001即为x.c=3,其余的位为补齐用。。。
[阅读全文 (414) | (已有条评论) ]