画表格

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a[11]={"┌","┬","┐","├","┼","┤","└","┴","┘","│","─"};
    int m,n;
	//cout<<a[0]<<endl;

    while (cin>>m>>n)
    {
      
			if(m!=0&&n!=0)
            for(int i=0;i<=2*m;i++)
            {

                for(int j=0;j<=2*n;j++)
                {
					
                    if(i==0&&j==0)
                    cout<<a[0];
					
					else if(i==2*m&&j==2*n)
                    cout<<a[8];
                    else if(i==0&&j==2*n)
                    cout<<a[2];
					else if(i%2==1&&j%2==0)
                    cout<<a[9];
					else if(i%2==0&&j%2==1)
                    cout<<a[10];
					else if(i%2==1&&j%2==1)
                    cout<<"  ";
					else if(i==2*m&&j==0)
                    cout<<a[6];
					else if(i%2==0&&j%2==0&&j!=0&&i!=0&&i!=2*m&&j!=2*n)
                    cout<<a[4];
					else if(i==0&&j%2==0&&j!=0&&j!=2*n)
                    cout<<a[1];
					else if(j==0&&i%2==0&&i!=0&&i!=2*m)
                    cout<<a[3];
					
                    else if(j==2*n&&i%2==0&&i!=0&&i!=2*m)
                    cout<<a[5];
                    
					else  if(i==2*m&&j%2==0&&j!=0&&j!=2*n)
					cout<<a[7];
					
				
                    if(j==2*n)
                    cout<<endl;
					//else break;
                    

                }
				if(i==2*m)
					cout<<endl;
            }
			else break;


    }
    return 0;
}

你可能感兴趣的:(画表格)