char*mycpy(char* dst,constchar* src){/*int index = 0;while(src[index]){dst[index] = src[index];index++;}dst[index] = '\0';return dst;*///指针版本char* ret = dst;while(*src !='\0'){*dst =*src;dst++;src++;}*dst ='\0';return ret;}intmain(){char s1[]="abc";char s2[]="abc";mycpy(s1,s2);return0;}
4.strchr/strrchr:在字符串中找字符
char* strchr(const char* s, int c);
char* strrchr(const char* s, int c);
返回NULL,表示没有找到
intmain(){char s[]="hello";char* p =strchr(s,'l');*p ='\0';printf("%s\n",p);//llo//寻找第二个lp =strchr(p+1,'l');printf("%s\n",p);//lo//把llo复制到另外的字符串中char* t =(char*)malloc(strlen(p)+1);strcpy(t,p);printf("%s\n",t);//llofree(t);//把l前面的字符串复制到另外的字符串char* q =(char*)malloc(strlen(s)+1);strcpy(q,s);printf("%s\n",q);//hefree(q);return0;}
效果 后端
using ProCleanTool.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;namespace P…
目录 一、题目
1、题目描述
2、输入输出
2.1输入
2.2输出
3、原题链接
二、解题报告
1、思路分析
2、复杂度
3、代码详解 一、题目
1、题目描述 Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time …