12 2019 档案
摘要:C++ 输入int类型出错处理 #include <iostream> #include <stdio.h> using namespace std; int main() { int n; char ch; while (true) { cout << "输入一个int类型的整数:"; // 如果
阅读全文
摘要:递归(Recursion) 栈(Stack) 先进后出(FILO, First In Last Out) 满足了函数调用(Call)和返回(Return)的顺序 需要维护每个函数调用信息直到返回后才释放,占用内存大 递归函数 基线条件(Base Condition) 递归条件(Recursive C
阅读全文
摘要:C swap实现任意数据类型调换 /* swap.c */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* 从<string.h>中包含memcpy函数 void *memcpy(void *p1, const void *
阅读全文
摘要:Python实现网络图形化界面多人聊天室 - Windows 项目名称:网络多人聊天室图形界面版本 项目思路: server.py 服务端文件,主进程中,创建图形化界面,询问地址(主机名,端口),点击开始进入聊天室。 创建子进程,开始网络连接,使用select.select循环接收客户端连接请求,使
阅读全文
摘要:C 单链表(Singly Linked List) /* * singly_linked_list.c * 单向链表 * sll = singly_linked_list * */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h>
阅读全文
摘要:C 顺序表(Sequence List) /* * sequence_list.c * 顺序表 * sl = sequence list * 线性表的顺序存储是指在内存中用地址连续的一块存储空间顺序存放线性表中的各数据元素 * 用这种存储形式的线性表称为顺序表 * */ #include <stdi
阅读全文
摘要:C 函数与指针(function & pointer) /* * function.c * 函数在C中的使用 * */ #include <stdio.h> int noswap(int x, int y) { /* * 函数会将传进来的参数复制一份,所以main中的x和y和noswap函数中的x和
阅读全文
摘要:C 指针(pointer) /* * pointer.c * 指针在C中的应用 * */ #include <stdio.h> int main(void) { /* * i是一个int类型,在内存中占4个字节,存储整数 * p是一个指向int类型的指针,指向i,存储i的地址,它本身也有一个地址 *
阅读全文
摘要:项目名称:多人聊天室项目结构: client.py server.py settings.py项目思路:服务端接收客户端连接,客户端发送信息给服务端,服务端将信息发送给所有客户端。项目实现:主进程负责接收键盘输入(sys.stdin.readline),使用multiprocessing.Proce
阅读全文
摘要:在C中实现string字符串,使用typedef将string定义为char *。 #include <stdio.h> #include <stdlib.h> #include <string.h> typedef char* string; string get_string(string);
阅读全文