将一句话里的单词倒置,句号不倒置
发布时间:2020-12-13 19:55:44 所属栏目:百科 来源:网络整理
导读:/* * welcome to EMC company. Output:comany EMC to welcome. */ #includestdio.h #includestdlib.h #includestring.h int main(){ char str[] = "welcome to EMC company."; char temp; int begin,end; int j = strlen(str) - 2,i = 0; while(j i){ temp =
/* * welcome to EMC company. Output:comany EMC to welcome. */ #include<stdio.h> #include<stdlib.h> #include<string.h> int main(){ char str[] = "welcome to EMC company."; char temp; int begin,end; int j = strlen(str) - 2,i = 0; while(j > i){ temp = str[i]; str[i] = str[j]; str[j] = temp; j--; i++; } printf("%sn",str); char endChar = str[0]; i = 0; while(str[i]){ if(str[i] != ' '){ begin = i; while(str[i]&&str[i]!=' '&&str[i]!='.') i++; //i = i-1; end = i-1; } while(end > begin){ temp = str[begin]; str[begin] = str[end]; str[end] = temp; end --; begin ++; } i++; } //str[i] = endChar; printf("%sn",str); return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- cocos2dx3.4 新声音引擎bug,自己修复了---带方法,希望引擎
- 浅谈ORACLE AWR single instance 一
- 高性能迷你React框架anujs1.1.2发布
- c# – 循环中的依赖注入
- 设计模式 reactor和proactor
- redux-form(V7.4.2)笔记(四)SelectingFormValuesForm实
- Ajax中对XMLHttpRequset对象的封装
- ajax – MarkLogic HTTP Server:设置CORS头
- PostgreSQL触发器动态生成多个表的代码
- PostgreSQL10当sequence 带有cache时,正常关闭PG Cluster时