-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva637_Booklet Printing.cpp
More file actions
63 lines (49 loc) · 1.39 KB
/
uva637_Booklet Printing.cpp
File metadata and controls
63 lines (49 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<bits/stdc++.h>
#define bug cout<<"bug";
#define pb(n) push_back(n)
#define lli long long int
#define fr(i,s,l) for(i=s;i<l;i++)
#define sf(n) scanf("%d",&n);
#include<stdlib.h>
using namespace std;
//uva 637
int main()
{
int page;
while(1)
{
scanf("%d",&page);
if(page==0)
{
break;
}
int first=1,i=0,total;
total=(int)ceil(page/4.0);
//printf("%d",total);
int last=total*4;
printf("Printing order for %d pages:\n",page);
for(i=1; i<=total; i++)
{
for(int j=1; j<=2; j++)
{
if(j&1 && (first<=page || last<=page))
{
if(last<=page)
printf("Sheet %d, front: %d, %d",i,last,first);
else
printf("Sheet %d, front: Blank, %d",i,first);
printf("\n");
}
else if(!(j&1) && (first<=page || last<=page))
{
if(last<=page)
printf("Sheet %d, back : %d, %d",i,first,last);
else
printf("Sheet %d, back : %d, Blank",i,first,last);
cout<<endl;
}
first++,last--;
}
}
}
}