Visual Cube

题目大意:

 输入长 宽 高 a,b,c 打印出相应图像 

用二维字符数组打印出的图行       为 2*(a+b)+1  乘2*(b+c)+1 的二维字符数组;

然后开始模拟

代码如下:

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
    char aa[200][200];
   int t;
   cin>>t;
   while(t--){
      memset(aa,'.',sizeof(aa));
      int i,j;
      int a,b,c;
      cin>>a>>b>>c;
      int h,l;
      h=(b+c)*2+1;
      l=(a+b)*2+1;
      int cc,k,g;
      int kkk=0,kk=0;
      int v=0;
      cc=2*a+1;k=2*b+1;g=2*c+1;
      int m=l-cc;
      int s;
      for(i=1;i<=h;i++){kk=0;kkk=0;
        for(j=1;j<=l;j++){
                if(i%2==1){
           if(i<2*c+1){
            if(j>m&&j%2==1){
            aa[i][j]='+';
            }
           }
         else{
              if(j>m&&j%2==1&&v<=l-2*a-1){
            aa[i][j]='+';
            }
         }
            if(j>m&&j%2==0&&kk<a){
                aa[i][j]='-';
                kk++;
            }
         }
         else{
                  if(i<=2*b+1&&j>m&&j%2==0){
                aa[i][j]='/';
                kkk++;

                  }
                  if(j>2*a+1&&i>2*b+1&&kkk>a&&j%2==0){
                      aa[i][j]='/';

                  }
            if(j>2*a+1&&i>2*b+1&&kkk>a&&j%2==1){
                      aa[i][j]='|';

                  }
                  if(i<2*b+1&&j>m&&j%2==1&&kkk>a){
                aa[i][j]='|';
                  }
                  if(i>2*b+1&&j>m&&j%2==1&&kkk<=a){
                    aa[i][j]='|';
                    kkk++;

                  }
         }  if(i>2*c+1){

             for(s=l-v;s<=l;s++){
                aa[i][s]='.';
             }

         }

        }
        if(m!=0)m--;
        else m=0;

         if(i>2*c+1){
                if(v!=l-2*a-1)v++;
        else v=l-2*a-1;}

       // cout<<v<<endl;
      }
        for(i=1;i<=h;i++){
            for(j=1;j<=l;j++){
                 printf("%c",aa[i][j]);
            }
       cout<<endl;
      }
      }
return 0;
   }

猜你喜欢

转载自blog.csdn.net/YANSHUOXU/article/details/81285112