码迷,mamicode.com
首页 > 其他好文 > 详细

软件工程——字符串操作

时间:2015-04-25 21:10:46      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

#include
  int main(){
  char sentence[100];
  int len=0,j,wordlen=0;
  gets(sentence);
  while(sentence[len]) len++;
  for(j=len-1;j>=0;j--){
  if(sentence[j]>=‘a‘&&sentence[j]<=‘z‘||sentence[j]>=‘A‘&&sentence[j]<=‘Z‘)
  {
  wordlen++;
  }
  else if(wordlen>0){
  printf("%*.*s",wordlen,wordlen,&sentence[j+1]);
  printf("%c",sentence[j]);
  wordlen=0;
  }
  else
  printf("%c",sentence[j]);
  }
  if(wordlen>0)
  printf("%*.*s",wordlen,wordlen,sentence);
  return 0;
  }

软件工程——字符串操作

标签:

原文地址:http://www.cnblogs.com/tibosi/p/4456537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!