UVa problem-Booklet printing

i am facing difficulty in solving UVa problem Booklet printing. th code is pasted below.

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,s,m,i,c;
    while ((scanf("%d",&n))==1)
    {
        if (n==0) break;
        printf ("printing order for %d pages: \n",n);
        if ((n%4)==0) s=(n/4);
        else s=(n/4)+1;
        m=s*4;
        c=1;
        for (i=1;i<=s;i++)
        {
            printf ("sheet %d, front: ",i);
            if (m>n) printf ("blank, ");
            else printf ("%d, ",m);
            printf ("%d\n",c);
            if (n==1) break;
            printf ("sheet %d, back : ",i);
            c++;
            printf ("%d, ",c);
            m--;
            if (m>n) printf ("blank\n");
            else printf ("%d\n",m);
            m--;
            c++;

        }
    }
}
//