字符串
life is fantastic
这个作者很懒,什么都没留下…
展开
-
自测-4 Have Fun with Numbers (20分)
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a diffe原创 2020-08-15 21:52:32 · 179 阅读 · 0 评论 -
习题11-6 查找子串 (20分)
本题要求实现一个字符串查找的简单函数 **方法一**: char *search(char *s, char *t){ int i,j,flag=0; i=j=0; char *p; while(t[j]!='\0'&&s[i]!='\0'){ //循环结束的条件 if(s[i]==t[j]&&flag==0){ //第一次找到第一个与s[]相同的字符 flag=1; p=&s[i]; //p指向子串t在s中的首原创 2020-08-02 09:02:11 · 2788 阅读 · 4 评论 -
习题11-5 指定位置输出字符串 (20分)
本题要求实现一个函数,对给定的一个字符串和两个字符,打印出给定字符串中从与第一个字符匹配的位置开始到与第二个字符匹配的位置之间的所有字符。 关于这题以下会给出三种解题思路 **第一种方法** char *match( char *s, char ch1, char ch2 ){ int i,flag=0; char *ch; for(i=0;s[i]!='\0';i++){ if(s[i]==ch1&&flag==0){ //第一次找到第一个字符匹配的位置时开始,第二次在遇到原创 2020-08-01 17:30:31 · 565 阅读 · 2 评论