Repository navigation
Expand file tree
/
Copy pathfunc2.cpp
More file actions
83 lines (79 loc) · 1.93 KB
/
Copy pathfunc2.cpp
File metadata and controls
83 lines (79 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "str_easy.h"
std::string itc_cmp_str(std::string str1, std::string str2, int num){
long long len1 = itc_len(str1);
if(len1 < num || num < 0 ){
return str1;
}
long long len2 = itc_len(str2);
std::string out1;
for(int i = 0; i < num; i++){
out1 += str1[i];
}
for(int i = 0; i < len2; i++){
out1 += str2[i];
}
for(int i = num; str1[i] != '\0'; i++){
out1 += str1[i];
}
std::string out;
for(int i = 0; i < len1; i++){
out += out1[i];
}
return out;
}
int itc_find_str(std::string str1, std::string str2){
int out;
bool istrue = 1;
for(long long i = 0; i < itc_len(str1); i++){
if(str1[i] == str2[0]){
for(long long j = 0; j < itc_len(str2); j++){
if(str1[i+j] != str2[j]){
istrue = 0;
break;
}
}
if(istrue){
return (int)i;
}
istrue = 1;
}
}
return -1;
}
std::string itc_three_str(std::string str1, std::string str2, std::string str3){
if(str2 == str3){
return str1;
}
int c;
while(itc_find_str(str1, str2) != -1){
std::string a, b;
c = itc_find_str(str1,str2);
for(int i = 0; i < c; i++){
a += str1[i];
}
for(int i = c + itc_len(str2); str1[i] != '\0'; i++){
b += str1[i];
}
str1 = a + str3 + b;
}
return str1;
}
int itc_max_char_on_end(std::string str){
int c = 0;
int maxc = -1;
for(long long i = 0; i < itc_len(str); i++){
if(str[i] <= '9' && str[i] >= '0'){
c++;
}
else{
if(c > maxc){
maxc = c;
}
c = 0;
}
}
if(c > maxc){
maxc = c;
}
return maxc;
}