Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
zen me bu dui#include <iostream> #include <stdio.h> using namespace std; int main() { int n; while ( cin >> n && n!=0 ) { cout<<"Printing order for "<< n<<" pages:"<<endl; int k=0 ,i=0,a=0; k= n/4 ; a=n%4; if(a==0 && n>=4) { for(i=1 ; i<=k ;i++) { printf("Sheet %d, front: %d, %d\n",i,4*k+2-2*i,2*i-1); printf("Sheet %d, back : %d, %d\n",i,2*i,4*k+1-2*i); } } if(n==1) { cout<<"Sheet 1, front: Blank, 1"<<endl; } if(n==2) { cout<<"Sheet 1, front: Blank, 1"<<endl; cout<<"Sheet 1, back : 2, Blank"<<endl; } if(n==3) { cout<<"Sheet 1, front: Blank, 1"<<endl; cout<<"Sheet 1, back : 2, 3"<<endl; } if(a==1 && n>4) { k++; cout<<"Sheet 1, front: Blank, 1"<<endl; cout<<"Sheet 1, back : 2, Blank"<<endl; cout<<"Sheet 2, front: Blank, 3"<<endl; cout<<"Sheet 2, Blank: 4, "<<n<<endl; for(i=3; i<=k ;i++) { printf("Sheet %d, front: %d, %d\n",i,4*k+2-2*i,2*i-1); printf("Sheet %d, back : %d, %d\n",i,2*i,4*k+1-2*i); } } if(a==2 && n>4) { k++; cout<<"Sheet 1, front: Blank, 1"<<endl; cout<<"Sheet 1, back : 2, Blank"<<endl; for(i=2; i<=k ;i++) { printf("Sheet %d, front: %d, %d\n",i,4*k+2-2*i,2*i-1); printf("Sheet %d, back : %d, %d\n",i,2*i,4*k+1-2*i); } } if(a==3 && n>4) { k++; cout<<"Sheet 1, front: Blank, 1"<<endl; cout<<"Sheet 1, back : 2, "<<n<<endl; for(i=2; i<=k ;i++) { printf("Sheet %d, front: %d, %d\n",i,4*k+2-2*i,2*i-1); printf("Sheet %d, back : %d, %d\n",i,2*i,4*k+1-2*i); } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator