PAT-1009 说反话
2016-02-23 22:38
344 查看
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; #define MAX 100 int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); char str[MAX], word[MAX][MAX]; gets(str); int j = 0, k = 0; char temp[MAX]; for (int i = 0; i < strlen(str); i++) { if (str[i] == ' ' || str[i] == '\0') { strcpy(word[k++], temp); j = 0; memset(temp, '\0', sizeof(temp)); continue; } temp[j++] = str[i]; if (i == strlen(str)-1) strcpy(word[k++], temp); } for(k--; k >= 0; k--) { cout << word[k]; if (k != 0) cout << " "; } return 0; }一年没写代码了,越写越烂。
相关文章推荐
- CF629C 在s两端在加两个串p和q 使得总长度为n,并且最后的s'符合规范的方法
- 19. Remove Nth Node From End of List
- linux 常见测试题
- vs 2015使用时有Cannot find one or more components.
- 深入理解Apache Flink核心技术
- 23种设计模式(8):中介者模式
- 如何检查STM32的HardFault_Handler故障
- 如何写PRD (附PRD案例)
- 深入浅出Java并发包—CAS机制
- oc之NSlog用法【2】
- python成长之路第三篇(1)_初识函数
- 《Effective C++》学习笔记——条款37
- C#Winform动态读取App.Config文件
- Git / Gitlab 奇淫技巧
- 深入浅出Java并发包—指令重排序
- Active Directory 站点和服务
- [SSH框架初学笔记]web.xml文件的基本配置
- PHP 安装包依赖关系管理工具Composer
- [Lintcode]Partition Array by Odd and Even
- iOS-多线程编程学习之NSOperation(四)