当前所在位置:珠峰网资料 >> 计算机 >> 软件水平 >> 正文
初级软考资料:面试系列4--以单词为最小单位翻转字符串
发布时间:2010/3/27 9:39:17 来源:城市学习网 编辑:admin

  面试系列4--以单词为最小单位翻转字符串
  原题:
  以单词为最小单位翻转字符串
  WritethefunctionStringreverseStringWordByWordthatreverses
  astringwordbyword.Forinstance,
  reverseStringWordByWord-->"blueishouseThe"
  reverseStringWordByWord-->"deadisZed"
  reverseStringWordByWord-->"All-in-one"
  代码:
  /
  created:2006/06/16
  filename:C:“DocumentsandSettings“Administrator“桌面“flwo“reverse.c
  filepath:C:“DocumentsandSettings“Administrator“桌面“flwo
  filebase:reverse
  fileext:c
  author:A.TNG
  version:0.0.1
  purpose:以单词为最小单位翻转字符串
  WritethefunctionStringreverseStringWordByWord
  thatreversesastringwordbyword.Forinstance,
  reverseStringWordByWord-->"blueishouseThe"
  reverseStringWordByWord-->"deadisZed"
  reverseStringWordByWord-->"All-in-one"
  #include<stdio.h>
  #include<string.h>
  #include<stdlib.h>
  /
  name:reverse_src_word_by_word
  params:
  des[out]输出字符串,des指向实现的空间
  src[in]输入字符串,需要处理的字符串
  return:
  处理完成后的des指针
  notes:
  以单词为最下单位翻转字符串
  author:A.TNG2006/06/169:06
  /
  charreverse_str_word_by_word
  {
  charp1,p2;
  charpsz_dest;
  if)
  returnNULL;
  /从src的最有一个字符开始遍历/
  p1=src+strlen-1;
  p2=p1;
  psz_dest=des;
  while
  {
  if
  {
  intn_len;
  /找到一个单词,拷贝单词/
  n_len=p2-p1;
  memcpy;
  psz_dest+=n_len;

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved