字典翻译 问答 其它 题目-例题(12.8)单词替换C语言描述输入一个字符串,以回车结束(字符串长度
问题标题:
题目-例题(12.8)单词替换C语言描述输入一个字符串,以回车结束(字符串长度
问题描述:

题目-例题(12.8)单词替换C语言

描述

输入一个字符串,以回车结束(字符串长度

丁怡心回答:
  #include   #include   #include   #defineMAX1000   #defineLEN20   voidInput(char*a,char*b,char*c){   gets(a);   gets(b);   gets(c);   }   voidSwap(char*str,char*FindWord,char*SwapWord){   intj,s,k,i=0,SwapWordLength,strLength,FindWordLength,n;   char*p1,*p2;   p1=str;   p2=FindWord;   strLength=strlen(str);//lengthoftheoriginalsentence   FindWordLength=strlen(FindWord);//lengthoftheoldword   SwapWordLength=strlen(SwapWord);//lengthofthenewword   n=SwapWordLength-FindWordLength;   while(*p1!=''){   if((*p1==*p2)&&(!isalpha(*(p1-1))))//isalpha:judgewhetherthechar_cisanenglishwordornot,ifyesreturn!0,ifnoreturn0   while((*p1==*p2)&&(*p2!=''))   {p1++;p2++;i++;}//i:recordhowmanycharshasbeenread   else{p1++;i++;}   if((*p2=='')&&(isalpha(*p1)==0)){   //findtheoldwordinthesentence   if(n
点击显示
其它推荐
热门其它推荐
  • 其它