This commit is contained in:
ranwenjie
2021-08-17 17:39:37 +08:00
parent 136b59671d
commit 1841228814
57 changed files with 15 additions and 21 deletions
+8 -1
View File
@@ -39,6 +39,7 @@ a = a - b;
最终示例代码:
```
//反转
void _reverse(char *start,char *end){
if ((start == NULL) || (end == NULL)) return;
while(start < end){
@@ -55,11 +56,15 @@ char *revert_by_word(char *source){
char *end = source;
char *start = source;
if (source == NULL) return NULL;
//end指针挪动到尾部
while (*end != '\0') end++;
end--;
//先全部反转
_reverse(start,end);
//按单词反转
start=end=source;
while(*start != '\0'){
if (*start == ' '){
@@ -94,7 +99,9 @@ char *left_rotate(char *str,int offset){
}
```
思路: 我们可以abcdef分成两部分,ab和cdef,内部逆序以后,整体再次逆序,就可以得到想要的结果了,也就是跟上面的问题是同样的问题。
思路: 我们可以abcdef分成两部分,ab和cdef,内部逆序以后,整体再次逆序,就可以得到想要的结果了。
也就是跟上面的问题是同样的问题。
## 判断字符串是否是回文
@@ -51,7 +51,7 @@ int main(int argc, char const *argv[])
char *test = "how are you ?";
printf("%s\n",_revert_by_word(test));
//char *test = "I am a student.";
//printf("%s\n",revert_by_word(test));
test = "I am a student.";
printf("%s\n",revert_by_word(test));
return 0;
}
@@ -264,7 +264,7 @@ void compress(char *src){
}
int count = 1;
char *back=src,forward=src+1;
char *back=src,*forward=src+1;
while(*forward){
@@ -3,11 +3,9 @@
二叉查找树变成双向链表
*/
strcut BSTreeNode{
typedef struct BSTreeNode{
int m_nValue;
BSTreeNode *m_pLeft,m_pRight;
struct BSTreeNode *m_pLeft, *m_pRight;
}BSTree;
void convertDoubleLinks(BSTree *root){
@@ -12,7 +12,7 @@
int main()
{
char ch = 'a';
foobar1(33, ch);
foobar1();
foobar2();
return 0;
}
@@ -1,9 +1,8 @@
#include "c13-1.c"
extern int *arr;
int main()
{
arr[1] = 100;
return 0;
}
@@ -8,17 +8,12 @@
#define test_file_path "./ip.txt"
#define ip_count 100000000 //随机1亿个IP
#define tmp_file_count 32
#define mem_count 128*1024*1028 //128MB个IP空间
int hash(unsigned i){
return i>>27;
}
int main(){
@@ -52,9 +47,6 @@ int main(){
}
}
//开始读测试数据IP,按IP,映射到32个文件中
FILE *testfd = fopen(test_file_path2,"r");
if (!testfd)
@@ -76,8 +68,6 @@ int main(){
}
// 依次读入每个文件并统计, hash_map 统计每个区间段的最大IP
int hash_map[mem_count];
int max_ip;