摘要:
1 #include <stdio.h> 2 #include <stdlib.h> 5 char*str1 = "ABDFLjlero我们都是saf";7 char* ToLower(char s[]) 8 { 9 static size_t i=sizeof(s); 10 11 for (i; i>=0; i--) { 12 if (s[i]>"A" && s[i]<"Z") { 13 s[i] += 26; 14 } 15 } 16 return s;}19 int A( 阅读全文
posted @ 2012-06-28 20:33
byfei
阅读(120)
评论(0)
推荐(0)
摘要:
#include #include char* str1 = "ABDFLjlero我们都是saf";char* ToLower(char s[]) { static size_t i=sizeof(s); for (i; i>=0; i-... 阅读全文
posted @ 2012-06-28 20:33
byfei
阅读(55)
评论(0)
推荐(0)
摘要:
#include <stdio.h>#include <string.h>#include <stdarg.h>#include <iostream>using namespace std;int strlen(char *a){if (0 == *a)return 0;elsereturn strlen(++a) + 1;}int main(void){char *p="1234567";cout<<strlen(p);return 0;}int strlen(char *a) { if(0 == *a) ret 阅读全文
posted @ 2012-06-28 20:32
byfei
阅读(185)
评论(0)
推荐(0)
摘要:
国际象棋有8×8格,每个格子可放一个棋子。皇后的规则是可以横、竖、斜移动。在一个棋盘放置8个皇后,并使它们互相无法威胁到彼此。答:以下是可执行C代码,采用非递归解法,你如果想了解皇后问题的算法的详细过程可看下面网址:http://www.cnjcw.cn/infoview/2005031720203563221270.html不过下面的代码是以列优先进行试探的,不是上面网址介绍的那样以行优先的,当然本质是一样的。#include<iostream.h>#defineQUEEN8//皇后数量intqueen[QUEEN];//下标代表所在列号,值代表所在行号,//如quee 阅读全文
posted @ 2012-06-28 20:31
byfei
阅读(310)
评论(0)
推荐(0)
摘要:
#include <iostream>using namespace std;class A{public: A(){ doSth(); } virtual void doSth(){cout<<("I am A");}};class B:public A{public: virtual void doSth(){ cout<<("I am B");}};int main(){B b;return 0;}I am A#include <iostream>using namespace std;class A 阅读全文
posted @ 2012-06-28 20:29
byfei
阅读(205)
评论(0)
推荐(0)
摘要:
已知strcat函数的原型是char *strcat (char *strDest, const char *strSrc);其中strDest 是目的字符串,strSrc 是源字符串。(1)不调用C++/C 的字符串库函数,请编写函数 strcat答:VC源码:char * __cdecl strcat (char * dst, const char * src){char * cp = dst;while( *cp )cp++; /* find end of dst */while( *cp++ = *src++ ) ; /* Copy src to end of dst */return 阅读全文
posted @ 2012-06-28 20:26
byfei
阅读(586)
评论(0)
推荐(0)
摘要:
编写strcat函数 已知strcat函数的原型是char *strcat (char *strDest, const char *strSrc);其中strDest 是目的字符串,strSrc 是源字符串。(1)不调用C++/C 的字符串库函数,请编写函数 ... 阅读全文
posted @ 2012-06-28 20:26
byfei
阅读(54)
评论(0)
推荐(0)
摘要:
在某些类里声明纯虚析构函数很方便。纯虚函数将产生抽象类——不能实例化的类(即不能创建此类型的对象)。有些时候,你想使一个类成为抽象类,但刚好又没有任何纯虚函数。怎么办?因为抽象类是准备被用做基类的,基类必须要有一个虚析构函数,纯虚函数会产生抽象类,所以方法很简单:在想要成为抽象类的类里声明一个纯虚析构函数。 这里是一个例子: class awov { public: virtual ~awov() = 0; // 声明一个纯虚析构函数 }; 这个类有一个纯虚函数,所以它是抽象的,而且它有一个虚析构函数,所以不会产生析构函数问题。但这里还有一件事:必须提供纯虚析构函数的定义: ... 阅读全文
posted @ 2012-06-28 20:14
byfei
阅读(573)
评论(0)
推荐(0)
摘要:
构造函数不能是虚的。只能有虚的析构函数 阅读全文
posted @ 2012-06-28 20:08
byfei
阅读(472)
评论(0)
推荐(0)
摘要:
试题1voidtest1(){charstring[10];char*str1="0123456789";strcpy(string,str1);}试题2voidtest2(){charstring[10],str1[10];inti;for(i=0;i<10;i++){str1[i]='a';}strcpy(string,str1);}试题3voidtest3(char*str1){charstring[10];if(strlen(str1)<=10){strcpy(string,str1);}}试题4: void GetMemory( cha 阅读全文
posted @ 2012-06-28 19:46
byfei
阅读(223)
评论(0)
推荐(0)

浙公网安备 33010602011771号