码迷,mamicode.com
首页 > 其他好文 > 详细

222

时间:2018-10-19 23:51:15      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:str   isp   cout   i++   height   turn   find   out   using   

 

#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;
}

 

222

标签:str   isp   cout   i++   height   turn   find   out   using   

原文地址:https://www.cnblogs.com/sea-stream/p/9819671.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!