split

File Split 1.0

跟風遠走 提交于 2020-04-02 15:17:28
main.cpp 1 #include <iostream> 2 #include <fstream> 3 #include <stdlib.h> 4 #include <string> 5 #include <windows.h> 6 7 using namespace std; 8 9 int main ( int argc, char* argv[] ) { 10 if ( argc != 4 && argc != 5 ) { 11 cout << "File Split 1.0" << endl; 12 cout << " Usage: fs <source file> <off begin> <off end> [<destination file>]" << endl; 13 cout << " e.g. fs app.exe 0 127 0_127.dat" << endl; 14 cout << " e.g. fs app.exe 0 127" << endl; 15 return -1; 16 } 17 fstream src ( argv[1], ios::in | ios::binary | ios::ate ); 18 if ( src.is_open() ) { 19 long long srcSize = static_cast<long long> (

Bash 命令 —— split

大兔子大兔子 提交于 2020-03-31 21:12:24
Split 分割一个大文件为多个小文件 使用: 1. split file 默认将文件以每5000行进行分割, 生成的文件名为xaa xab xac xad .... 2. split -l 100 file 设置文件以每 100 行进行分割,后缀默认为两个字符,前缀默认为x,生成的文件名为xaa xab xac xad .... 3. split -d -l 100 file 设置文件以每 100 行进行分割,后缀默认为两位数字,前缀默认为x,生成文件为x00 x01 x02 x03 .... 4. split -d -l 100 file prefix 设置文件以每 100 行进行分割,后缀默认为两位数字,前缀设置为prefix,生成文件为prefix00 prefix01 prefix02 pefix03 .... 5. split -d -l 100 -a 3 file prefix 设置文件以每 100 行进行分割,后缀为3位数字,前缀为prefix,生成文件为prefix000 prefix001 prefix002 pefix003 .... 选项: -l 设置分割行数 -d 设置后缀为数字 -a 设置后缀为几位 来源: https://www.cnblogs.com/xiaodi-js/p/12608109.html

leetcode 1316

自作多情 提交于 2020-03-29 10:11:05
题目解析:求回声字符串的个数,也就是求头半段等于后半段的字符串的个数。 解法一:遍历长度为l的每一子字符串,时间复杂度为O(n^2) , 判断子字符串的的前半段是否等于后半段,总的时间复杂度为O(N^3).会超时; class Solution { public: int distinctEchoSubstrings(string text) { int len = text.size() ; //vector<vector<int>> dp(len , vector<int>(len , 0)) ; //int modl = 1e18 + 7 ; unordered_set<string> res ; for(int split = 1 ; split < len ; split++) for(int l = 1 ; split - l >= 0 && split + l <= len ; l++) if(text.compare(split - l , l , text , split , l) == 0) res.insert(text.substr(split , l)) ; return res.size() ; } };    解法二:优化:使用kmp算法,求每一子字符串的kmp长度是否大于等于子字符串长度的一半,若等于一半就一定满足条件

Split a list of JSON blobs delimited by commas (ignoring commas inside a JSON blob) [duplicate]

烈酒焚心 提交于 2020-03-28 06:55:56
问题 This question already has answers here : Additional text encountered after finished reading JSON content: (2 answers) Closed last month . Here's a weird one. I'm given an ill-conceived input string that is a list of JSON blobs, separated commas. e.g.: string input = "{<some JSON object>},{JSON_2},{JSON_3},...,{JSON_n}" And I have to convert this to an actual list of JSON strings ( List<string> ). For context, the unsanitary "input" list of JSONs is read in directly from a .txt file on disk,

度分秒转经纬度

空扰寡人 提交于 2020-03-28 02:41:41
01. Option Explicit 02. '================================ 03. ' 经纬度角度格式到弧度格式的转换 04. ' 05. ' http://www.cnhup.com/ 06. '================================ 07. Type TDFM 08. D As Integer 09. F As Integer 10. M As Integer 11. End Type 12. Function DFM2JW(strDFM As String ) 13. Dim aDFM As TDFM 14. Dim vecSplit As Variant 15. 16. vecSplit = Split(strDFM, "°" , 2) 17. aDFM.D = Val(vecSplit(0)) 18. vecSplit = Split(vecSplit(1), "′" , 2) 19. aDFM.F = Val(vecSplit(0)) 20. aDFM.M = Val(vecSplit(1)) 21. 22. DFM2JW = aDFM.D + aDFM.F / 60 + aDFM.M / 3600 23. End Function 下面是经典的带小数点的度转度分秒 TEXT(A1/24,"[h]°m′s

3.26作业

旧街凉风 提交于 2020-03-26 23:41:05
文件内容如下,标题为:姓名,性别,年纪,薪资 egon male 18 3000 alex male 38 30000 wupeiqi female 28 20000 yuanhao female 28 10000 要求:从文件中取出每一条记录放入列表中,列表的每个元素都是{’name’:’egon’,’sex’:’male’,’age’:18,’salary’:3000}的形式 with open(r'db.txt', 'r', encoding='utf-8')as f: res = [{"name": line.split()[0], "sex": line.split()[1], "age": line.split()[2], "salary": line.split()[3], } for line in f] print(res)    根据1得到的列表,取出薪资最高的人的信息 res = max(lis, key=lambda lis: lis['salary']) print(res)   根据1得到的列表,取出最年轻的人的信息 res = min(lis, key=lambda lis: lis['age']) print(res)   将names=[’egon’,’alex_sb’,’wupeiqi’,’yuanhao’]中的名字全部变大写 names=[

Python中的split()函数的用法

旧巷老猫 提交于 2020-03-25 05:35:35
函数:split() Python中有split()和os.path.split()两个函数,具体作用如下: split():拆分字符串。通过指定分隔符对字符串进行切片,并返回分割后的字符串列表(list) os.path.split():按照路径将文件名和路径分割开 一、函数说明 1、split()函数 语法:str.split(str="",num=string.count(str))[n] 参数说明: str:表示为分隔符,默认为空格,但是不能为空('')。若字符串中没有分隔符,则把整个字符串作为列表的一个元素 num:表示分割次数。如果存在参数num,则仅分隔成 num+1 个子字符串,并且每一个子字符串可以赋给新的变量 [n]:表示选取第n个分片 注意:当使用空格作为分隔符时,对于中间为空的项会自动忽略 2、os.path.split()函数 语法:os.path.split('PATH') 参数说明: 1.PATH指一个文件的全路径作为参数: 2.如果给出的是一个目录和文件名,则输出路径和文件名 3.如果给出的是一个目录名,则输出路径和为空文件名 二、分离字符串 string = "www.gziscas.com.cn" 1.以'.'为分隔符 print(string.split('.')) ['www', 'gziscas', 'com', 'cn'] 2.分割两次

Codeforces Round #567 (Div. 2) B. Split a Number

江枫思渺然 提交于 2020-03-23 06:16:11
Codeforces Round #567 (Div. 2) B. Split a Number Dima worked all day and wrote down on a long paper strip his favorite number n consisting of l digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive integer without leading zeros. After that he will compute the sum of the two integers and write it down on a new strip. Dima wants the resulting integer to be as small as possible, because it increases the chances that the sum will fit

Recursive split-list function LISP

僤鯓⒐⒋嵵緔 提交于 2020-03-21 19:29:32
问题 The split-list function takes a list and returns a list of two lists consisting of alternating elements of the input. I wrote the following: (defun split-list (L) (cond ((endp L) (list NIL NIL)) (t (let ((X (split-list (cdr L)))) (cond ((oddp (length L)) (list (cons (first L) (first X)) (cadr X))) (t (list (first X) (cons (first L) (cadr X))))))))) The output is as expected for odd numbered lists, the first list consisting of the 1st, 3rd, 5th etc elements and the second part consisting of

Recursive split-list function LISP

笑着哭i 提交于 2020-03-21 19:26:15
问题 The split-list function takes a list and returns a list of two lists consisting of alternating elements of the input. I wrote the following: (defun split-list (L) (cond ((endp L) (list NIL NIL)) (t (let ((X (split-list (cdr L)))) (cond ((oddp (length L)) (list (cons (first L) (first X)) (cadr X))) (t (list (first X) (cons (first L) (cadr X))))))))) The output is as expected for odd numbered lists, the first list consisting of the 1st, 3rd, 5th etc elements and the second part consisting of