ytu 1338: 制作表格



 
 

1338: 制作表格

Time Limit: 1 Sec   Memory Limit: 128 MB Submit: 11   Solved: 5 [ Submit][ Status][ Web Board]

Description

在中文Windows环境下,控制台窗口中也可以用特殊符号拼出漂亮的表格来。 比如:         ┌─┬─┐ │ │ │ ├─┼─┤ │ │ │ └─┴─┘         其实,它是由如下的符号拼接的:     左上 = ┌     上 =  ┬     右上 =  ┐     左 =  ├     中心 =  ┼     右 =  ┤     左下=  └     下 =  ┴     右下 =  ┘     垂直 =  │     水平 =   ─ 本题目要求编写一个程序,根据用户输入的行、列数画出相应的表格来。

Input

Output

Sample Input

3 2

Sample Output

┌─┬─┐
│ │ │
├─┼─┤
│ │ │
├─┼─┤
│ │ │
└─┴─┘
代码
#include <iostream>
#include <string>
using namespace std;
int main ()
{
     string s[] = { "┌" , "┬" , "┐" , "├" , "┼" , "┤" , "└" , "┴" , "┘" , "│" , "─" };
     int x,y;
     int i,j;
     cin>>x>>y;
     cout<<s[0]<<s[10];
     for (i=0;i<y-1; i++)
         cout<<s[1]<<s[10];
     cout<<s[2]<<endl<<s[9];
     for (i = 0; i<y;i++)
         cout<< " " <<s[9];
     cout<<endl;
     for (i = 0; i < x - 1; i++)
     {
         cout<<s[3]<<s[10];
         for (j = 0; j < y-1; j++)
             cout<<s[4]<<s[10];
         cout<<s[5]<<endl<<s[9];
         for (j = 0; j < y; j++)
             cout<< " " <<s[9];
         cout<<endl;
     }
     cout<<s[6]<<s[10];
     for (i = 0; i < y - 1; i++)
         cout<<s[7]<<s[10];
     cout<<s[8]<<endl;
     return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值