简单模拟题,稍微注意即可,不罗嗦,直接贴代码.
Code
1#include <iostream>
2using namespace std;
3
4void PrintSheet(int sheet_num, int i, int j, int n, bool isFront)
5{
6 if(i > n && j > n)
7 return;
8 cout << "Sheet " << sheet_num << ", " << (isFront ? "front: " : "back : ");
9 if(isFront)
10 {
11 if(j > n)
12 cout << "Blank";
13 else
14 cout << j;
15 cout << ", " << i << endl;
16 }
17 else
18 {
19 cout << i << ", ";
20 if(j > n)
21 cout << "Blank";
22 else
23 cout << j;
24 cout << endl;
25 }
26}
27
28int _tmain(int argc, _TCHAR* argv[])
29{
30 int n;
31 while(cin >> n && n != 0)
32 {
33 int sheet = n / 4;
34 int fullfill_n = n;
35 if(n % 4 != 0)
36 {
37 fullfill_n = (sheet + 1) * 4;
38 }
39
40 cout << "Printing order for " << n << " pages:" << endl;
41
42 int current_sheet = 1;
43
44 for(int i = 1, j = fullfill_n; i < j;)
45 {
46 PrintSheet(current_sheet, i, j, n, true);
47 ++i;
48 --j;
49 PrintSheet(current_sheet, i, j, n, false);
50 ++i;
51 --j;
52 ++current_sheet;
53 }
54 }
55 return 0;
56}
57
58
posted on 2009-03-26 21:11
肖羽思 阅读(299)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ