微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

/* * 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; }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐