zoukankan      html  css  js  c++  java
  • 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;
    }

  • 相关阅读:
    Python的垃圾回收机制
    标准库
    常用数据库命令备忘录(持续增量更新)
    Springboot配置excludePathPatterns不生效问题 (2020-06-28 22:21)
    Android 子线程无法刷新UI界面
    如何实现Java线程的 阻塞/唤醒(和暂停/继续 类似)
    Android Studio 如何获取 text文本内容
    Css设置最优先
    CentOS7下MySQL服务启动失败原因及解决方法
    Js/Jquery获取input file的文件名
  • 原文地址:https://www.cnblogs.com/sea-stream/p/9819671.html
Copyright © 2011-2022 走看看