摘要: 写一个函数: int print_num(int k){}; 要求函数功能为打印k的降序,直到0结束,即如果k=5,即打印: 5 4 3 2 1 0 要求: 不能用 if , if else, switch, ?: , while, for , do while, goto 语句解法1:利用构造函数和数组 1 class Printer 2 { 3 public: 4 static int counter; 5 Printer() 6 { 7 cout<<counter<<endl; 8 counter--; 9 } 10 }; 11 int P... 阅读全文
posted @ 2012-08-26 16:16 持幕 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 1 #include <unistd.h>; 2 #include <sys/types.h>; 3 4 main () 5 { 6 pid_t pid; 7 pid=fork(); // 这个地方开始分化为两个进程空间(所谓的一次调用,两个返回) 8 9 if (pid < 0)10 printf("error in fork!");11 else if (pid == 0)12 printf("i am the child process, m... 阅读全文
posted @ 2012-08-26 15:49 持幕 阅读(123) 评论(0) 推荐(0) 编辑