Untitled

救命啦!
mail@pastecode.io avatar
unknown
plain_text
2 years ago
820 B
4
Indexable
Never
#include <stdio.h>
void A(int x,int y,int e);
int main(void){
    int x,y;
    scanf("%d %d",&x,&y);
    A(x-1,y-1,0);
    return 0;
}

void A(int x,int y,int e){
    int a,b,E;
    a=y;
    b=x;
    E=e;
    if((x+y-2*e)%2==0){
        b=x-1;
    }
    if((y-e)%2==0){
        E=e+1;
    }
    if((x-e)%2==0){
        a=y-1;
    }
    if(e<=x && e<=y){
        for(int i=e;i<=x;i=i+2){
            printf("%d %d\n",i,y);
        }
        for(int i=a-1;i>=e;i=i-2){
            printf("%d %d\n",x,i);
        }
        for(int i=b-1;i>=e;i=i-2){
            printf("%d %d\n",i,e);
            if(y==1){
                break;
            }
        }
        for(int i=E+1;i<y;i=i+2){
            printf("%d %d\n",e,i);
        }
        A(x-1,y-1,e+1);
    }
    
        
}