- 博客(11)
- 资源 (1)
- 收藏
- 关注
原创 reverse
反转字符串的程序,比如”abcdefghi” -> “ihgfedcba” #include <stdio.h> #include <string.h> char *reverse(char *set) { int i,j; char temp; if(set == NULL) return NULL; for(i = 0,j = strlen(set) - 1; i < j; i++,j--) { temp = set[i]; set.
2021-10-08 22:04:40
119
原创 mystrstr
#include <stdio.h> #include <string.h> //strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串。 //如果是,则该函数返回str2在str1中首次出现的地址;否则,返回NULL。 char *mystrstr(const char *set,const char *res) { int i,j,x; char *temp = set; if(set == NULL || res == NULL) .
2021-10-08 22:01:21
208
原创 mystrlen
#include <stdio.h> int mystrlen(const char *str) { int i; if(str == NULL) return -1; for(i = 0; str[i] != '\0'; i++); return i-1; } int main(void) { int res; char str[] = "hello world!"; res = mystrlen(str); printf("------res = %d---.
2021-09-29 19:25:18
250
原创 mystrcat
#include <stdio.h> #include <string.h> int mystrcpy(char *str,const char *res) { int i; if(str == NULL || res == NULL) { return -1; } for(i = 0; res[i] != '\0'; i++) str[i] = res[i]; str[i] = res[i]; return 0; } int main(void).
2021-09-29 19:23:21
121
原创 mystrcmp
#include <stdio.h> int mystrcmp(const char * set,const char * res); int main(void) { int x; char set[] = "he"; char res[] = "hello"; x = mystrcmp(set,res); printf("x = %d\n",x); return 0; } int mystrcmp(const char * set,const char * res).
2021-09-28 21:28:07
222
原创 mystrcpy
#include <stdio.h> #include <string.h> int mystrcpy(char *str,const char *res) { int i; if(str == NULL || res == NULL) { return -1; } for(i = 0; res[i] != '\0'; i++) str[i] = res[i]; str[i] = res[i]; return 0; } int main(void).
2021-09-27 22:24:25
232
原创 C快速排序
#include <stdio.h> //快速排序 void Quick_Sort(int arr[],int head,int tail) { if(head > tail) return ; int i,j,temp,res; i = head; j = tail; temp = arr[head]; while(i != j) { while(arr[j] >= t...
2021-09-26 23:06:59
104
原创 字符串库函数
#include <string.h> 1、char *strcpy(char *dest,const char *src):从src指针指向的内存中拷贝\0及以前的数据到 dest指针指向的内存中,返回值为第一参数记录的地址 2、char *strncpy(char *dest,const char *src,size_t n):从src指针指向的内存中拷贝n个字节的数据到dest指针指向的内存中,返回值为第一参数记录的地址 3、size_t strlen(const char *s)
2021-09-26 21:10:27
109
原创 C选择排序
#include <stdio.h> //选择排序:把大值和小值往两边摞动 int main(void) { int x, i, j, temp, min, max, right, left = 0; int arr[] = {5,61,4,20,25}; printf("请选择升序or降序排序(1表示升序,2表示降序):"); scanf("%d",&x); right = sizeof(arr) / sizeof(int) - 1; ...
2021-09-26 21:02:02
85
原创 关于sscanf字符串的分割
intmain() { char*buf="zhangsan man 21"; chara[9],b[4]; intc; sscanf(buf,"%s%s%d",a,b,&c); printf("%s\n%s\n%d\n",a,b,c); return0; } 如:char *buf = "zhangsan-man-21"; 则:sscanf(buf,"%s-%s...
2021-09-23 21:45:33
624
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅