首页 > 代码库 > UVa 637 - Booklet Printing
UVa 637 - Booklet Printing
题目:模拟输出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; }
UVa 637 - Booklet Printing
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。