UVa 637 - Booklet Printing
2016-04-10 18:57
459 查看
题目:模拟输出n页书的装订打印状态。
分析:模拟。页数为(n+3)/ 4,仅仅有n不超过半篇时会输出半篇。
说明:好多曾经做过的题目(⊙_⊙)。
分析:模拟。页数为(n+3)/ 4,仅仅有n不超过半篇时会输出半篇。
说明:好多曾经做过的题目(⊙_⊙)。
#include <cstdlib> #include <cstring> #include <cstdio> int book[30][4]; int main() { int n; while (~scanf("%d",&n) && n) { int page = (n+3)/4; memset(book ,0 ,sizeof(book)); int count = 1; for (int i = 1 ; i <= page ; ++ i) { book[i][1] = count ++; if (count > n) break; book[i][2] = count ++; if (count > n) break; } if (count <= n) for (int i = page ; i >= 1 ; -- i) { book[i][3] = count ++; if (count > n) break; book[i][0] = count ++; if (count > n) break; } printf("Printing order for %d pages:\n",n); for (int i = 1 ; i <= page ; ++ i) { if (book[i][0] || book[i][1]) { printf("Sheet %d, front: ",i); if (book[i][0]) printf("%d, ",book[i][0]); else printf("Blank, "); if (book[i][1]) printf("%d\n",book[i][1]); else printf("Blank\n"); } if (book[i][2] || book[i][3]) { printf("Sheet %d, back : ",i); if (book[i][2]) printf("%d, ",book[i][2]); else printf("Blank, "); if (book[i][3]) printf("%d\n",book[i][3]); else printf("Blank\n"); } } } return 0; }
相关文章推荐
- 四则运算网页版
- 微信开放平台SDK笔记
- MVC的一些个人看法
- java多线程中的等待唤醒机制--多生产者多消费者问题
- 实现安卓页面的跳转
- ubuntu搭建nodejs开发环境
- Hadoop2.6.0官方MapReduce文档翻译 之 二
- JSP内置对象out
- 【Oracle】3.模糊查询
- 线程池
- 使用ssh公钥密钥自动登陆linux服务器
- 算法--基础编程模型
- JVM核心机制_深入类加载器JAVA220-223
- 20145232 韩文浩 《Java程序设计》第6周学习总结
- 一元多项式乘法
- Hadoop2.6.0官方MapReduce文档翻译 之 一
- openstack 软重启和硬重启的区别
- 系统初始化脚本
- C++封装、继承、多态
- MOXA串口网关工作不正常解决方法