222

 

#include <iostream>     // cout
#include <algorithm>    // find_end
#include <vector>       // vector
using namespace std;
void paint(int,int);
void judge(int [],int [],int,int,int,int,int);
void paint(int i,int j){
    cout<<i<<","<<j<<endl;
}
void judge(int A[],int B[],int s,int times,int left,int width,int height){
    if(A[0]>B[0]){
        if(A[1]>B[1]){
            if(s==0){
                for(int k=0;k<times;k++){
                    for(int l=0;l<height;l++){
                        paint(B[0]+l,B[1]);
                        }
                    }
                    left=-1;
                }
                for(int i=B[0];i<=A[0];i++){
                    for(int j=B[1];j<=A[1];j++){
                        paint(i,j);
                    }
                }
            }
            for(int i=B[0];i<=A[0];i++){
                for(int j=B[1];j<=A[1];j++){
                    paint(i,j);
                }
            }
        }else if (A[1]<B[1]){
            for(int i=B[0];i<=A[0];i++){
                for(int j=A[1];j<=B[1];j++){
                    paint(i,j);
                }
            }
        }else{
            for(int i=B[0];i<=A[0];i++){
                for(int j=B[1];j<=A[1];j++){
                    paint(i,j);
                }
            }
        }
    }else if (A[0]<B[0]){
        if(A[1]>B[1]){
            for(int i=A[0];i<=B[0];i++){
                for(int j=B[1];j<=A[1];j++){
                    paint(i,j);
                }
            }
        }else if (A[1]<B[1]){
            for(int i=A[0];i<=B[0];i++){
                for(int j=A[1];j<=B[1];j++){
                    paint(i,j);
                }
            }
        }else{
            for(int i=A[0];i<=B[0];i++){
                for(int j=A[1];j<=B[1];j++){
                    paint(i,j);
                }
            }
        }
    }else{
        if(A[1]>B[1]){
            for(int i=B[0];i<=A[0];i++){
                for(int j=B[1];j<=A[1];j++){
                    paint(i,j);
                }
            }
        }else if (A[1]<B[1]){
            for(int i=A[0];i<=B[0];i++){
                for(int j=A[1];j<=B[1];j++){
                    paint(i,j);
                }
            }
        }else{
            for(int i=A[0];i<=B[0];i++){
                for(int j=A[1];j<=B[1];j++){
                    paint(i,j);
                }
            }
        }
    }
}
int main () {
    int A[] = {1,1};
    int B[]={5,5};
    int width,height,times=-1,left=-1,s=-1;
    width=abs(A[0]-B[0]);
    height=abs(A[1]-B[1]);
    if(width>height){
        s=0;
        times=width/height;
        left=width%height;
        
    }else if(width<height){
        s=1;
        times=height/width;
        left=height%width;
    }
    
    if(times==1&&left==0){
        judge(A,B,s,times,left,width,height);
    }
 
    return 0;
}

 

posted @ 2018-10-19 22:36  anobscureretreat  阅读(184)  评论(0编辑  收藏  举报