将一句话里的单词倒置,句号不倒置

/* * 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("%s\n",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("%s\n",str); return 0; }

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...