加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间: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; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读