上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 48 下一页
摘要: 1、如果f是一个函数,则f();指调用该函数,而f;却什么也不做,准确的说,这个语句计算函数f的地址,但并不调用该函数。2、C语言允许初始化列表出现多余的逗号,是为了对称。如:int days[] = {1, 2, 3, 4, 5, 6, 7,};最后有逗号是正确的。3、malloc要注意是否申请成功,和最后的free。4、strcpy的目标要申请好了内存。5、溢出的结果是未定义的。6、strcpy只用于字符串复制,memcpy用于一般内存的复制。strcpy根据\0判断结束否,memcpy根据第三个参数的长度判断结束。实现如下:char * strcpy(char * dest, const 阅读全文
posted @ 2013-03-17 21:41 helloweworld 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 第一章 C:穿越时空的迷雾1、auto关键字显然是摆设,意思是“在进入程序块时自动进行内存分配”,与全局静态分配或在堆上动态分配相反。2、register关键字。3、“任何学习或使用c语言的人都应当使用ANSI C,而不是K&R C”。4、未确定的(unspecified)——在某些正确情况下的做法,标准并未明确规定应该怎么做。如:计算参数的顺序。未定义的(undefined)——在某些不正确情况下的做法,但标准并未规定应该怎么做。如:有符号整数溢出该采取什么行动。约束条件(a constraint)——这是一个必须遵守的限制或要求。注:未确定的不会导致错误,但是未定义的可能会导致错误 阅读全文
posted @ 2013-03-17 17:54 helloweworld 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 一、面向对象的理解!参考http://www.51testing.com/html/10/n-824210.html此题可引申到c与c++的对比。要点:1、谈到面向过程时,引出函数和执行的顺序性。2、谈到面向对象时,引出封装、继承和多态,并进一步解释。尤其是多态:编译时的多态(重载)和运行时的多态(覆盖,即虚函数实现)。3、再举一个例子,区别面向过程和面向对象。(学生类例子) 阅读全文
posted @ 2013-03-11 16:04 helloweworld 阅读(185) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <string.h>using namespace std;int main() { int tmp; int num = 0; char s[] = "123"; for (int i = 0; i < strlen(s); i++) { tmp = s[i] - '0'; num = num * 10 + tmp; } cout << num;} 阅读全文
posted @ 2013-03-11 11:56 helloweworld 阅读(215) 评论(0) 推荐(0) 编辑
摘要: /*数字转换成字符串*/#include <iostream>#include <stdio.h>using namespace std;int main(){ int num = 12345; char str[20]; sprintf(str, "%d", num); cout << str;}/*数字转换成字符串*/#include <iostream>#include <stdio.h>using namespace std;int main(){ int num; char str[20] = " 阅读全文
posted @ 2013-03-08 20:26 helloweworld 阅读(181) 评论(0) 推荐(0) 编辑
摘要: /*回文数判断*/#include <iostream>#include <string>using namespace std;int main(){ string str; cin >> str; int backward = 0; int farward = str.size() - 1; for ( ; backward <= farward; backward++, farward--) { if (str[backward] != str[farward]) { break; } } if (backward > farward) { 阅读全文
posted @ 2013-03-08 19:25 helloweworld 阅读(194) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python3class Student(object): def __init__(self): #默认有此函数,自定义时运行自定义的。实例化时首次运行该函数 print("First function to run when create a instance.") def getName(self): self.name = ... 阅读全文
posted @ 2013-03-06 23:18 helloweworld 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 在python3.0以后的版本中,raw_input和input合体了,取消raw_input,并用input代替,所以现在的版本input接收的是字符串,你可以用:x = int(input("x: "))x = input("input x:")print(int(x)+1) 阅读全文
posted @ 2013-03-04 19:22 helloweworld 阅读(281) 评论(0) 推荐(0) 编辑
摘要: def funName(x): print("call funName") return (x + 1) 阅读全文
posted @ 2013-03-04 14:37 helloweworld 阅读(108) 评论(0) 推荐(0) 编辑
摘要: for eachNum in [0, 1, 2]: print(eachNum)#range()内建函数生成0 1 2... for eachNum in range(3): print(eachNum) foo = 'abc'for c in foo: print(c)输出:012012abc 阅读全文
posted @ 2013-03-04 13:50 helloweworld 阅读(176) 评论(0) 推荐(0) 编辑
上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 48 下一页