********************************found****************************
returnsq;}/*返回值*/
16
字符串逆序输出。
********************************found****************************
fun(chara)/*指针*/
********************************found****************************
{if(*a){fun(a+1);printf("%c"*a);}}/*输出格式*/
17
删除字符串s中所有空白字符。
fun(char*p)
{inti,t;charc[80];
********************************found****************************
For(i=0,t=0;p[i];i++)/*关键字*/
if(!
isspace(*(p+i)))c[t++]=p[i];
********************************found****************************
c[t]="\0";strcpy(p,c);}/*字符串结束标志*/
18
将p字符串中每个单词最后一个字母改成大写。
voidfun(char*p)
{intk=0;
for(;*p;p++)if(k)
********************************found****************************
{if(p=='')/*指针*/
********************************found****************************
{k=0;*(p-1)=toupper(*(p-1))}}/*语句标志*/
elsek=1;}
19
将s字符串中出现的t1子串全部替换成t2子串。
intfun(char*s,char*t1,char*t2,char*w)
{inti;char*p,*r,*a;strcpy(w,s);
while(*w){p=w;r=t1;
********************************found****************************
while(r)if(*r==*p){r++;p++;}elsebreak;/*指针*/
if(*r=='\0'){a=w;r=t2;
********************************found****************************
while(*r){*a=*r;a++;r++}/*语句标志*/
w+=strlen(t2);}elsew++;}}
20
从s字符串中找出t子串个数。
intfun(char*s,char*t)
{intn;char*p,*r;n=0;
while(*s){p=s;r=t;
********************************found****************************
while(*r)if(*r==*p){r++;p++}elsebreak;/*语句标志*/
********************************found****************************
if(r=='\0')n++;s++;}returnn;}/*指针*/
21
将s字符串中最后一次出现的t1子串替换成t2子串。
voidfun(char*s,char*t1,char*t2,char*w)
{inti;char*p,*r,*a;strcpy(w,s);
********************************found****************************
while(w){p=w;r=t1;/*指针*/
********************************found****************************
while(*r)IF(*r==*p){r++;p++;}elsebreak;/*关键字*/
if(*r=='\0')a=w;w++;}r=t2;while(*r){*a=*r;a++;r++;}}
22
计算s字符串中含有t串的数目。
#defineN80
intfun(char*s,char*t)
{intn;char*p,*r;n=0;
********************************found****************************
while(*s){p=s;r=p;
while(*r)if(*r==*p){r++;p++;}elsebreak;
********************************found****************************
if(*r=0)n++;s++;}returnn;}/*判定条件*/
23
求出字符串中最后一次出现的子串地址。
char*fun(char*s,char*t)
{char*p,*r,*a;
********************************found****************************
a=Null;/*空指针*/
while(*s){p=s;r=t;
********************************found****************************
while(*r)if(r==p){r++;p++;}elsebreak;/*指针*/
if(*r=='\0')a=s;s++;}returna;}
24
将字符串p中所有字符复制到字符串b中,每复制三个字符后插入一个空格。
voidfun(char*p,char*b)
{inti,k=0;
while(*p){i=1;
********************************found****************************
while(i<3||*p){b[k]=p;k++;p++;i++;}/*指针*/
********************************found****************************
if(*p){b[k++]="";}}b[k]='\0';}/*字符*/
25
在字符串str中找出ASCII码值最大的字符,将其放在第一个位置上,并将该字符前的原字符向后顺序移动。
voidfun(char*p)
{charmax,*q;inti=0;max=p[i];
while(p[i]!
=0)
********************************found****************************
{if(max
********************************found****************************
wihle(q>p){*q=*(q-1);q--;}p[0]=max;}/*关键字*/
26
读入一个英文文本行,将其中每个单词第一个字母改成大写。
********************************found****************************
include/*命令行*/
********************************found****************************
upfst(charp)/*函数返回值类型*/
{intk=0;for(;*p;p++)
if(k){if(*p=='')k=0;}elseif(*p!
=''){k=1;*p=toupper(*p);}}
27
把b字符串逆序存放,将a串字符和b串字符,按排列顺序交叉合并到c数组。
voidfun(char*a,char*b,char*c)
{inti,j;charch;i=0;j=strlen(b)-1;
********************************found****************************
while(i>j){ch=b[i];b[i]=b[j];b[j]=ch;i++;j--;}/*下标*/
while(*a||*b)
********************************found****************************
{If(*a){*c=*a;c++;a++;}/*关键字*/
if(*b){*c=*b;c++;b++;}}*c=0;}
28
统计字符串中各元音字母的个数。
voidfun(char*s,intnum[5])
{intk,i=5;
********************************found****************************
for(k=0;k
for(;*s;s++){i=-1;
********************************found****************************
switch(s)/*指针*/
{case'a':
case'A':
{i=O;break;}case'e':
case'E':
{i=1;break;}
case'i':
case'I':
{i=2;break;}case'o':
case'O':
{i=3;break;}
case'u':
case'U':
{i=4;break;}}
if(i>=0)num[i]++;}}
29
将字符串s中位于奇数位置字符或ASCII码为偶数的字符放入字符串t中。
#defineN80
voidfun(char*s,chart[])
{inti,j=0;
for(i=0;i********************************found****************************
if(i%2&&s[i]%2==0)t[j++]=s[i];/*逻辑或*/
********************************found****************************
t[i]='\0';}/*下标*/
30
依次取出字符串中所有数字字符。
voidfun(char*s)
{inti,j;
for(i=0,j=0;s[i]!
='\0';i++)
********************************found****************************
if(s[i]>='0'&&s[i]<='9')s[j]=s[i];/*下标移动*/
********************************found****************************
s[j]="\0";}/*字符串结束标志*/
31
判断字符ch是否与str所指串中某个字符相同;若相同,则什么也不做,若不同,则将其插在串的最后。
********************************found****************************
voidfun(charstr,charch)/*指针*/
{while(*str&&*str!
=ch)str++;