转跳点:  

这道题我记得谷歌 2012 年校招,百度201年校招好向出过。所以我想,了一个及其奇葩的代码。(模拟了栈的理念)代码有些奇葩。

)

  我利用了scanf函数遇到“ ”停止的特性模拟了栈的push,用printf遇到'\0'结束模拟了pop,设定了一个栈顶指针指向当前栈顶元素。因为栈的先进后出的特性,加上%s输出的特性,就完成了对单词顺序的反转

代码实现如下:

 1 #include <stdio.h>
2 #include <stdlib.h>
3 #define MAXSIZE 100
4
5 typedef struct
6 {
7 char Str[MAXSIZE / 4];
8 } Stack;
9
10 int main()
11 {
12 int bottom = -1;
13 Stack str[MAXSIZE];
14
15 while (scanf("%s", &str[++bottom]) != EOF && str[bottom].Str[0] != '#')
16 ;
17 while (bottom != 0)
18 printf("%s%s", str[bottom].Str, 0 == --bottom ? "" : " ");
19
20 return 0;
21 }

结构体数组

  这个是用二维数组实现的:

 1 #include <stdio.h>
2 #include <stdlib.h>
3 #define MAXSIZE 100
4
5 int main()
6 {
7 int bottom = -1;
8 char str[MAXSIZE][MAXSIZE / 4];
9
10 while (scanf("%s", &str[++bottom]) != EOF && str[bottom][0] != '\n')
11 ;
12
13 while (bottom != 0)
14 printf("%s%s", str[bottom], 0 == --bottom ? "" : " ");
15
16 return 0;
17 }

二维数组

   PAT不易,诸君共勉!

P 1008 说反话的更多相关文章

  1. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  2. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  3. POJ 1008 Maya Calendar

    链接:http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Subm ...

  4. BZOJ 1008 题解

    1008: [HNOI2008]越狱 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 7845  Solved: 3359[Submit][Status] ...

  5. HDU 4777 Rabbit Kingdom (2013杭州赛区1008题,预处理,树状数组)

    Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  6. 【BZOJ】1008: [HNOI2008]越狱(快速幂)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1008 刚开始看不会做啊,以为是dp,但是数据太大!!!所以一定有log的算法或者O1的算法,,,,还 ...

  7. PAT (Top Level) Practise 1008 Airline Routes(Tarjan模版题)

    1008. Airline Routes (35) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given a ...

  8. PAT乙级 1009. 说反话 (20)

    1009. 说反话 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 给定一句英语,要求你编写程序,将句中 ...

  9. PAT乙级 1008. 数组元素循环右移问题 (20)

    1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数,在不允 ...

随机推荐

  1. 使用C语言实现文件的操作

    #include <stdio.h> int main(int argc, char* argv[]) { // 创建文件类型 FILE* file; char buf[1024] = { ...

  2. Using SmartAssembly with MSBuild

    SmartAssembly 6 SmartAssembly 6 documentation Building your assembly Using SmartAssembly with MSBuil ...

  3. win7系统实现内外网同时连接图文教程

    解决方案:修改路由表 在工作中,经常会遇到切换内外网的网络情况,通常情况下都是断开/连接网络,很麻烦.我们可以使用route命令来解决此类问题,route add.route delete.route ...

  4. hdu 2838 Cow Sorting 树状数组求所有比x小的数的个数

    Cow Sorting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. luffy 那点事

    1 虚拟环境创建 2 后台:Django项目创建 3 后台配置 4 数据库配置 5 user模块User表 6 前台 7 前台配置 8 前端主页 9 后端主页模块设计 10 xadmin 后台管理 1 ...

  6. Linux文件系统层次结构标准FHS

    文件系统层次结构标准(英语:Filesystem Hierarchy Standard,FHS)定义了Linux操作系统中的主要目录及目录内容.FHS由Linux基金会维护. 当前版本为3.0版,于2 ...

  7. re模块补充 configparse模块

    import rere.findall("(?:abc)+","abcabcabc")--->['abcabcabc'] import configpar ...

  8. 跳蚤[BZOJ4310](后缀数组+二分答案传判定)

    不知道后缀数组的请退回去! 题面: 题目描述 很久很久以前,森林里住着一群跳蚤.一天,跳蚤国王得到了一个神秘的字符串,它想进行研究.首先,他会把串分成不超过 k 个子串,然后对于每个子串 S,他会从S ...

  9. Time Series_1_BRKA Case

    Berkshire Hathaway (The most expensive stock ever in the world) 1.1 Download data require(quantmod) ...

  10. dataset的reparation和coalesce

    /** * Returns a new Dataset that has exactly `numPartitions` partitions, when the fewer partitions * ...