11 2019 档案
摘要:Given a hash table of size N, we can define a hash function H(x)=x%N. Suppose that the linear probing is used to solve collisions, we can easily obtai
阅读全文
摘要:实现QQ新帐户申请和老帐户登陆的简化版功能。最大挑战是:据说现在的QQ号码已经有10位数了。 输入格式: 输入首先给出一个正整数N(≤10^5),随后给出N行指令。每行指令的格式为:“命令符(空格)QQ号码(空格)密码”。其中命令符为“N”(代表New)时表示要新申请一个QQ号,后面是新帐户的
阅读全文
摘要:The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers.
阅读全文
摘要:给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人。 输入格式: 输入首先给出正整数N(≤10^5),为通话记录条数。随后N行,每行给出一条通话记录。简单起见,这里只列出拨出方和接收方的11位数字构成的手机号码,其中以空格分隔。 输出格式: 在一行中给出聊天狂人的手机号码及其通话次数,其
阅读全文
摘要:ls命令用来显示目标列表。 常用参数: -l :以长格式显示目录下的内容列表。输出信息从左向右依次包括文件名,文件类型,权限模式,硬连接数,所有者、组、文件大小和文件的最后修改时间等; -a :显示所有档案及目录; -r :以文件名反序排列并输出目录内容列表; -t :用文件和目录的更改时间排序;
阅读全文
摘要:DIR_INC = ./include DIR_SRC = ./src DIR_OBJ = ./obj DIR_BIN = ./bin DIR_LIB = -Wl,-rpath=/home/exbot/shareWin/UnityCamera/TestCamera/lib \\ -L/home/ex
阅读全文
摘要:/* mycp.c */ #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<fcntl.h> #include<string.h> #include<dirent.h> #include<sys/types.h> #in
阅读全文
摘要:头文件: #include<unistd.h> 函数定义: int getopt(int argc,char * const argv[ ],const char * optstring); 参数说明: argc、argv: 由main函数参数直接传递过来。 optstring: 是一个包含合法选项
阅读全文
摘要:/* who_test.c */ #include<stdio.h> #include<string.h> #include<getopt.h> #include<time.h> #include<stdlib.h> #include<stdbool.h> #include<utmp.h> //设置
阅读全文
摘要:utmp结构体定义如下: structutmp { short int ut_type; // 登录类型 pid_t ut_pid; // login进程的pid char ut_line[UT_LINE_SIZE]; // 登录装置名,省略了"/dev/" char ut_id[4]; // In
阅读全文
摘要:/* float.c */ #include<stdio.h> #include<string.h> int main() { FILE *fp = fopen("Data.txt","w+"); float f[3][5] = {{-3.41, 5.63, 6, 7.8, 1.3}, {4.5 ,
阅读全文
摘要:import re n = input() for i in range(int(n)): str = input() if re.match(r'A*PA+TA*',str): a = re.split(r'[P|T]',str)if (a[0] * len(a[1]) == a[2]): pri
阅读全文
摘要:公共部分代码 /* common.h */ #ifndef COMMON_H #define COMMON_H #include <arpa/inet.h> #include <ctype.h> #include <dirent.h> #include <errno.h> #include <fcn
阅读全文
摘要:打印root可以使用可执行文件数。 echo "root's bins: $(find ./ -type f | xargs ls -l | sed '/-..x/p' | wc -l)" 命令解释 1.echo 输出后面双引号的的内容 2. find ./ -type f 查找当前目录下文件类型为
阅读全文
摘要:Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation tha
阅读全文
摘要:配置文件读写系统方法和测试函数 #include"readConfig.h" #define CFGNAME "./test.txt" void mymenu() { printf(" \n"); printf("1 Test Write Config file\n"); printf("2 Tes
阅读全文
摘要:The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist
阅读全文
摘要:给定公司N名员工的工龄,要求按工龄增序输出每个工龄段有多少员工。 输入格式: 输入首先给出正整数N(≤10^5),即员工总人数;随后给出N个整数,即每个员工的工龄,范围在[0, 50]。 输出格式: 按工龄的递增顺序输出每个工龄的员工个数,格式为:“工龄:人数”。每项占一行。如果人数为0则不输出该
阅读全文
摘要:函数原型: #include <sys/types.h > #include <sys/socket.h> int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); 参数说明:
阅读全文
摘要:According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insert
阅读全文
摘要:According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insert
阅读全文
摘要:给定N个(长整型范围内的)整数,要求输出从小到大排序后的结果。 本题旨在测试各种不同的排序算法在各种数据情况下的表现。各组测试数据特点如下: 数据1:只有1个元素; 数据2:11个不相同的整数,测试基本正确性; 数据3:103个随机整数; 数据4:104个随机整数; 数据5:105个随机整数; 数据
阅读全文
摘要:/* common.h */ /*服务器端口信息*/ #define PORTLINK ".charport" /*缓存限制*/ #define MAXNAMELEN 256 #define MAXPKTLENE 2048 /*信息类型钉钉*/ #define LIST_GROUPS 0 #defi
阅读全文
摘要:函数原型: #include<netdb.h> struct hostent * gethostbyaddr(const char *addr, socklen_t len, int family); 函数功能: 返回对应于给定地址的主机信息。 参数说明: addr:指向网络字节顺序地址的指针。 l
阅读全文
摘要:函数原型: #include<sys/socket.h> int getsockname(int sockfd, struct sockaddr *localaddr, socklen_t *addrlen); int getpeername(int sockfd, struct sockaddr
阅读全文
摘要:LIBS+= -L $$PWD/../HKUnifyCamera_one/Debug -lHKUnifyCamera -luuid -Wl,-rpath=$$PWD/../HKUnifyCamera_one/Debug $$PWD:表示获取当前文件所在路径,用于相对路径编译 -Wl,-rpath:程
阅读全文
摘要:函数原型: #include <unistd.h> int symlink(const char * oldpath, const char * newpath); 函数说明: symlink()以参数newpath 指定的名称来建立一个新的连接(符号连接)到参数oldpath 所指定的已存在文件.
阅读全文
摘要:函数原型; #include<unistd.h> ssize_t readlink(const char *path, char *buf, size_t bufsiz); 函数说明: readlink()会将参数path的符号链接内容存储到参数buf所指的内存空间,返回的内容不是以\000作字符串
阅读全文
摘要:函数原型: include<stdlib.h> char *getenv(char *envvar); 函数说明: getenv()用来取得参数envvar环境变量的内容。参数envvar为环境变量的名称,如果该变量存在则会返回指向该内容的指针。环境变量的格式为envvar=value。getenv
阅读全文
摘要:按照字符读取和写入 #include<stdio.h> #include<string.h> #include<stdlib.h> int fputc_func(char *filename) { int i = 0; FILE *fp = NULL; char buf[64] = "this is
阅读全文
摘要:#include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct Teacher { char name[64]; int age; char *pname2; }teacher; /* 编译器的=号操作会把指针变量的值,从
阅读全文
摘要:/*** point_practice.c ***/ #include<stdio.h> #include<string.h> #include<stdlib.h> int sort( char **myp1 /*in*/, int num1, char (*myp2)[30], int num2,
阅读全文
摘要:Given the relations of all the activities of a project, you are supposed to find the earliest completion time of the project. Input Specification: Eac
阅读全文
摘要:假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。 比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比
阅读全文
摘要:现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。 输入格式: 输入数据包括城镇数目正整数N(≤1000)和候选道路数目M(≤3N);随后的M行对应M条道路,每行给出3个正整数,分别是该条道路直接连通的两个城镇的编号以及该道路改建的
阅读全文
摘要:index函数 函数定义: #include<strings.h> char *index(const char *s, int c); 函数说明: 找出参数s字符串中第一个出现参数c的地址,然后将该字符串出现的地址返回。字符串结束字符(NULL)也视为字符串的一部分。 返回值: 如果找到指定的字符
阅读全文
摘要:gethostname():返回本地主机的标准主机名 原型: #include<unistd.h> int gethostname(char *name, size_t len); 参数说明: name: 接收缓冲区,字节长度必须为len,或更长,存获取主机名 len: 接收缓冲区name的最大长度
阅读全文
摘要:socket函数 int socket(int protofamily, int type, int protocol); //返回sockfd,即描述符 功能: socket 函数对应于普通文件的打开操作。普通文件的打开操作返回一个文件描述字,而 socket() 用于创建一个 socket 描述
阅读全文
摘要:常见的网络拓扑 两台主机通信的过程:应用进程产生消息,经由主机的 TCP/IP 协议栈发送到局域网(LAN),最后经过广域网(目前最大的广域网的因特网)中的网络设备(路由器)传给目的主机所在的局域网(LAN),最后经过局域网(LAN)将报文传送个目的主机,经由主机 TCP/IP 协议栈处理,将消息递
阅读全文
摘要:有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径。如果有若干条路径都是最短的,那么需要输出最便宜的一条路径。 输入格式: 输入说明:输入数据的第1行给出4个正整数N、M、S、D,其中N(2≤N≤
阅读全文
摘要:This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of d
阅读全文
摘要:/* * 文件名:mypwd.c * 描述: 实现简单的pwd命令 */ #include<stdio.h> #include<stdlib.h> #include<dirent.h> #include<sys/types.h> #include<sys/stat.h> #include<strin
阅读全文
摘要:哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等。反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫。另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将
阅读全文
摘要:“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。 “六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。
阅读全文
摘要:Linux文件系统数如下: 在 Linux 系统中,文件系统通过目录"包含"子目录及文件的方式,来组织成一个树状结构。那么目录到底是如何"包含"其他目录及文件的呢? 目录,在 Linux 中,其实也是一种文件,所以它也是由“inode+数据块”构成的。而其文件内容是一个列表,每一个列表项记录“ino
阅读全文
摘要:一般情况下,每个存储设备或存储设备的分区(存储设备是硬盘、软盘、U盘 ..)被格式化为文件系统后,都会有两部份,一部份是iNode,另一部份是Block。Block是用来存储数据用的,而iNode就是用来存储这些数据的信息,这些信息包括文件大小、属主、归属的用户组、读写权限等。 在 Linux 中的
阅读全文
摘要:This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of d
阅读全文
摘要:结构体中含有二级指针的内存分配和释放 #include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct Teacher { char name[64]; char *alisname; char **stuname; int
阅读全文
摘要:给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。 输入格式: 输入第1行给出2个整数N(0)和E,分别是图的顶点数和边数。随后E行,每行给出一条边的两个端点。每行中的数字
阅读全文
摘要:In 1953, David A. Huffman published his paper "A Method for the Construction of Minimum-Redundancy Codes", and hence printed his name in the history o
阅读全文
摘要:版本1: 调用系统接口getcwd,实现路径打印。 实验结果:
阅读全文