练习题
来源:互联网 发布:网络渠道销售授权书 编辑:程序博客网 时间:2024/04/28 06:38
逆序句子但不改变单词的拼写
#include <stdio.h>#include <string.h>#define MAX_SIZE 1024void reverse_word(char *s2){ int i = 0; int j = 0; int low = 0; char temp; while(s2[i] != '\0') { if(s2[i] == ' ') { for(j = 0; j < (i - low) / 2; j++) { temp = *(s2 + low + j); *(s2 + low + j) = *(s2 + i - 1 - j); *(s2 + i - 1 - j) = temp; } low = i + 1; } i++; } for(j = 0; j < (i - low) / 2;j++) { temp = *(s2 + low + j); *(s2 + low + j) = *(s2 + i - 1 - j); *(s2 + i - 1 - j) = temp; }}char * reverse_str(char *s1,int len){ int i; char temp; for(i = 0; i < len / 2; i++) { temp = *(s1 + i); *(s1 + i) = *(s1 + len - i - 1); *(s1 + len - i - 1) = temp; } reverse_word(s1); return s1;}int main(){ char str[MAX_SIZE]; printf("please input a string:\n"); gets(str); char * result = reverse_str(str,strlen(str)); printf("the result is %s",result); return 0;}
0 0
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 练习题
- 苏嵌25 16.12.02
- 单例设计模式
- ProgressBar的样式及用法
- kmp 快速模式串匹配
- 微软认知服务 人脸识别 API 之 概述
- 练习题
- 写爬虫过程中的一个问题
- mac 设置代理做抓包调试
- 突破github的100M单个大文件上传限制
- Android内存优化总结
- NYoj811变态最大值
- codeforces 621E Wet Shack and blocks dp+矩阵幂优化!
- python 组织菜谱
- centos7 foxit reader占用CPU过高问题解决方案