Original title: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=178
The book is printed in half with the big open paper. For example, a booklet of 4 pages, in order to facilitate binding, printed on the outside 1, 4 pages, the inside printing 2, 3 pages, so that after folding can be in accordance with normal reading habits page.
The sensory algorithm is more handsome than the online family's algorithm
#include <iostream>
using namespace std;
int main ()
{
int n,sheet,four_n;
int front[2],back[2];
while (cin>>n&&n!=0)
{
if (n%4) four_n=n+4-n%4;
else four_n=n;
SHEET=FOUR_N/4;
Front[0]=four_n;
Front[1]=1;
back[0]=2;
back[1]=four_n-1;
cout<< "Printing order for" <<n<< "pages:" <<endl;
for (int i=0;i<sheet;i++)
{
if (n==1)
{
cout<< "Sheet 1, Front:blank, 1" <<endl;
break;
}
Front[0]=four_n-2*i;
Front[1]=1+2*i;
Back[0]=2+2*i;
Back[1]=four_n-1-2*i;
cout<< "Sheet" <<i+1<< ", Front:";
if (front[0]>n) cout<< "Blank";
else cout<<front[0];
cout<< "," <<front[1]<<endl;
cout<< "Sheet" <<i+1<< ", Back:";
cout<<back[0]<< ",";
if (back[1]>n) cout<< "Blank" <<endl;
Else cout<<back[1]<<endl;
}}}