软件工程——字符串操作

#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;
  }

posted on 2015-04-25 20:27  愤怒的提伯斯  阅读(163)  评论(0编辑  收藏  举报

导航