当前位置: 首页 > Linux

optiver笔试

时间:2023-04-06 03:35:52 Linux

笔试基础题dfsedawktopnetstatbash基本操作,seqhead打印文件前10行,查看网络路由信息(route)查看loadaverage信息(w或top)权限分配,私钥权限区别路由器和交换机之间如何挂载swap分区grep命令挂载算法1读取文件host_access_log_00.txt,将输出结果保存在bytes_host_access_log_00.txt中并返回。读取文件的每一行,包括主机名时间戳请求HTTP响应代码Bytesa.b.x[01/Jul/1995:00:00:06-0400]"GET/shuttle/countdown/HTTP/1.0"2003985并输出所有字节>5000文件行数,输出文件行数相加的结果思路&难点文件输入输出流的处理定义文件名for循环求bytes的值,使用stol转换intmain(){//读取字符串文件名freopen("data","r",stdin);字符串文件名;cin>>文件名;intcnt=0;长长的bytesCnt=0;std::ifstreamfin(文件名,std::ios::in);//读入整个文件charline[1024]={0};字符串数="";while(fin.getline(line,sizeof(line))){std::stringstreamword(line);for(inti=0;i<10;++i){word>>num;}if(stol(num)>5000){cnt++;bytesCnt+=stol(num);}num.clear();}stringOutPutPath="bytes_"+文件名;ofstream输出文件;outfile.open(OutPutPath,ios::out|ios::app);如果(!outfile){返回0;}outfile<#include#include#includeusingnamespacestd;intmain(){freopen("数据","r",标准输入);字符串文件名;cin>>文件名;ifstream鳍(文件名,ios::in);字符字节[1024];字符串主机=“”;地图<字符串,整数>米;while(fin.getline(bytes,sizeof(bytes))){stringstreamword(bytes);单词>>主机;//主机名m[host]++;主机.clear();//注意清空}stringpath="records_"+filename;ofstream输出文件(路径,ios::out||ios::app);for(autox:m){outfile<