c语言倒置字符串将一句话中的单词倒置

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
yesterday is history,tomorrow is a mystery,but today is a gift.
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(1749)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'编写一个C函数,将“I am from shanghai”倒置为“shanghai from am I”',
blogAbstract:'
编写一个C函数,将“I am from shanghai”倒置为“shanghai from am I”即将句子中的单词位置倒置,并不改变单词内部结构
代码如下:
#include &stdio.h&
void RevStr(char *src){&&&&&& char *start = src , *end = src , *ptr =
&&& while(*ptr++ != \'\\0\')&&& {&&&&&&& if(*ptr == \' \' || *ptr == \'\\0\')',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:5,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'yesterday is history,tomorrow is a mystery,but today is a gift.',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}数据结构C语言单链表建立、输出、倒置、倒置输出_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
数据结构C语言单链表建立、输出、倒置、倒置输出
上传于||文档简介
&&数​据​结​构​中​利​用​C​语​言​实​现​单​链​表​建​立​、​输​出​、​倒​置​、​倒​置​输​出
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
你可能喜欢用C++实现,将一句话里的单词进行倒置的方法详解
字体:[ ] 类型:转载 时间:
本篇文章是对用C++实现,将一句话里的单词进行倒置的方法进行了详细的分析介绍,需要的朋友参考下
用C++语言实现,将一句话中的单词进行倒置(单词之间倒转,单词本身不倒置),标点符号不导致。比如一句话“I come from tianjin. “,倒置后变成“tianjin. from come I ”。C常见的库函数有: 代码如下:int& strstr(const char* string,const char* substring)&& 用于返回主串中子串的位置以后的所有字符。比如主串是“”,子串是“234”,则返回“”。char*&& strcpy(char* DestStr,const char* SrcStr)&& 复制字符串函数&& int&&& strcmp(const char* str1,const char* str2)&&& 比较两个字符串&& char*& strcat(char* destStr,const char* srcStr)&&&&& 连接字符串&& 没有太合适题意的库函数,因此想办法不用库函数,自己进行倒置。下面的是自己的实现,不足之处,还望指正!!! 代码如下:#include "stdafx.h"#include &iostream&char *strReverse(char * sourcestr){&int j = 0, i = 0,begin,&char *str =&&j = strlen(str) - 1;&cout && " string = " && str &&&//先将字符串进行全部倒转 变成 .nijnaiT morf emoc I&while (j & i)&{&&temp = str[i];&&str[i] = str[j];&&str[j] =&&j --;&&i ++;&}&cout && " string = " && str &&&//然后进行按单词部分反转,遇到空格,则判断出一个单词结束&i = 0;&while (str[i])&{&&if (str[i] != ' ')&&{&&&begin =&&&while (str[i] && str[i] != ' ')&&&{&&&&end =&&&&i++;&&&}&&&if (str[i] == '\0') //字符串的结束符&&&{&&&&i--;&&&}&&}&&while (end & begin)&&{&&&temp = str[begin];&&&str[begin] = str[end];&&&str[end] =&&&end --;&&&begin ++;&&}&&i ++;&}&cout && " string = " && str &&&}int _tmain(int argc, _TCHAR* argv[]){&char str[] = "I come from Tianjin.";&strReverse(str);&return 0;}
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 c语言 二进制倒置 的文章

 

随机推荐