[Login|Register]
New post

Show post

Search forum

Read post
我这个代码怎么老是输出错误?在哪的问题啊! [ Topic ] 2013-03-07 15:08:54 lara
#include<stdio.h>
int main()
{
    int n,i;
    while (scanf("%d",&n)!=EOF)
    {
        if(n==0)
            break;
        else
        {
            if(n==1)
            {
                printf("Printing order for %d pages:\n",n);
                printf("Sheet 1, front: Black, %d\n",n);
            }
            else
            {
                for(i=0;n>i*4;i++);
                int a=i*4-n;
                int sum=i*4+1;
                int s;
                if(a==0)
                    printf("Printing order for %d pages:\n",n);            
                
                if(a==1)
                {
                    printf("Printing order for %d pages:\n",n);            
                    printf("Sheet 1, front: Black, 1\n");
                    printf("Sheet 1, back: 2, %d\n",n);
                    
                }
                if(a==2)
                {
                    printf("Printing order for %d pages:\n",n);            
                    printf("Sheet 1, front: Black, 1\n");
                    printf("Sheet 1, back: 2, Black\n");
                    
                }
                if(a==3)
                {
                    printf("Printing order for %d pages:\n",n);            
                    printf("Sheet 1, front: Black, 1\n");
                    printf("Sheet 1, back: 2, Black\n");
                    printf("Sheet 2, front: Black, 3\n");
                    printf("Sheet 2, back: 4, %d\n",n);
                }
                for(s=(a+1)/2+1;s<=i;s++)
                {
                    printf("Sheet %d, front: %d, %d\n",s,sum-(2*s-1),2*s-1);
                    printf("Sheet %d, back: %d, %d\n",s,2*s,sum-2*s);
                    
                }
                
            }
        }
    }
    return 0;
}
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 2.8ms with 2 query(s).