1. Erste Version: C++, Evgeni Pavlidis


/************************************************
Algorithmen und Problemloesungen mit C++,
http://www.algorithmen-und-problemloesungen.de
Copyright @2007 by Doina Logofatu

- ‹berarbeitet -
Evgeni Pavlidis
Accepted: 0.010

************************************************/
#include <iostream>

using namespace std;

int main(){
short n, i, k, T, nrPages;
while(true)
{
cin >> n;
if(n==0)
return 0;

cout<<"Printing order for "<< n << " pages:\n";

T=n;
while(n%4) n++;

nrPages=n/4;
for(i=1; i<=nrPages; i++)
{
k=2*(i-1);
cout<<"Sheet "<< i <<", front: ";

if(n-k>T)
cout<<"Blank, ";
else
cout<<n-k<< ", ";

cout<<k+1<<endl;

if(k+2>T && n-k-1>T)
continue;

cout<<"Sheet "<< i <<", back : ";

if(k+2>T)
cout<<"Blank, ";
else
cout<<k+2<<", ";

if(n-k-1>T)
cout<<"Blank";
else
cout<<n-k-1;

cout<<endl;
}
}
return 0;
}

2. Zwiete Version, C,


/************************************************
Algorithmen und Problemloesungen mit C++,
http://www.algorithmen-und-problemloesungen.de
Copyright @2007 by Doina Logofatu

- ‹berarbeitet -
Evgeni Pavlidis
Accepted: 0.000

************************************************/
#include <stdio.h>


int main()
{
int n, i, k, T, nrPages;
while(1)
{
scanf("%d\n",&n);
if(n==0)
return 0;

printf("Printing order for %d pages:\n", n);

T=n;
while(n%4) n++;

nrPages=n/4;

for(i=1; i<=nrPages; i++)
{
k=2*(i-1);
printf("Sheet %d, front: ", i);

if(n-k>T)
printf("Blank, ");
else
printf("%d, ", n-k);

printf("%d\n",k+1);

if(k+2>T && n-k-1>T)
continue;

printf("Sheet %d, back : ", i);

if(k+2>T)
printf("Blank, ");
else
printf("%d, ",k+2);

if(n-k-1>T)
printf("Blank");
else
printf("%d",n-k-1);

printf("\n");
}
}
return 0;
}