#define LL long long
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define pri(a) cout<<a<<endl
#define prii(a,b) cout<<a<<" "<<b<<endl
#define hi printf("Hello World\n")
#define WRITE(fn) freopen(fn, "w", stdout);
#define pcs printf("Case %d: ", ++cs);
using namespace std;
/// Think a real world situation. you are told to print a book of sheets. as you need to use 1 press sheet
/// for 4 pages. so take required sheets ceil(n/4.0) . count totalpage in takne sheet.
/// loop from your last sheet to frst sheet.. if u're on sheet that's greater than our input sheet nmbr then leave it blank
/// *** Think Real World; Assume yourself a printsman."" The problem is solved"
int main()
{
int n;
while(cin>>n and n)
{
if(n==1)
{
printf("Printing order for %d pages:\n", n);
printf("Sheet 1, front: Blank, 1\n");
continue;
}
int ReqSheet = ceil(n/4.0);
int TotalPageInSheet = ReqSheet * 4;
printf("Printing order for %d pages:\n", n);
int lst = TotalPageInSheet;
int fst = 1;
FOR(i,1,ReqSheet)
{
printf("Sheet %d, front: ", i);
if(lst > n)
printf("Blank, ");
else
printf("%d, ",lst);
printf("%d\n", fst);
lst--;
fst++;
printf("Sheet %d, back : ", i);
printf("%d", fst);
if(lst > n)
printf(", Blank\n");
else
printf(", %d\n",lst);
lst--;
fst++;
}
}
return 0;
}
No comments:
Post a Comment