思维导图:
作业:使用多文件编译【复习】
三个文件:main.c head.h test.c
1.通过指针指向字符串,实现字符串逆置 void MyStrRev(char *p) //p要逆序的字符串
代码
main.c:
test.c:
head.h:
输出:
2.字符串连接 char *MyStrcat(char *dest,const char *src)//dest:连接到dest字符串中,src字符串不变
代码
main.c:
test.c:
head.h:
输出:
3.字符串比较函数int MyStrcmp(const char *s1,const char *s2) s1存储第一个字符串 s2存储第二个字符串
代码
main.c:
test.c:
head.h:
输出:
4.字符串拷贝char *MyStrcpy(char *dest,const char *sec) dest:拷贝后的字符串 src源字符串
代码
main.c:
test.c:
head.h:
输出:
5.字符串长度long Mystrlen(const char *s1) s1存储字符串
main.c:
test.c:
head.h:
输出:
6.使用递归实现斐波那契 FibonaciRec(n-1)+FibonaciRec(n-2)
main.c:
test.c:
head.h:
输出:
6.实现单词的逆置例如:char str[]=“hello my student”,输出结果是“student my hello”
main.c:
test.c:
head.h:
输出: