
C
jwzyyds
冲向云霄!
展开
-
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 · 95 阅读 · 0 评论 -
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 · 186 阅读 · 0 评论 -
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 · 226 阅读 · 0 评论 -
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 · 101 阅读 · 0 评论 -
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 · 203 阅读 · 0 评论 -
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 · 210 阅读 · 0 评论 -
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 · 82 阅读 · 0 评论 -
C冒泡排序
今日分享–冒泡排序原创 2021-09-25 17:29:08 · 80 阅读 · 0 评论 -
字符串库函数
#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 · 86 阅读 · 0 评论 -
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 · 68 阅读 · 0 评论 -
关于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 · 578 阅读 · 0 评论