您的位置:首页 > 其它

hdu2500做一个正气的杭电人

2016-01-16 12:28 239 查看
做一个正气的杭电人

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 9900 Accepted Submission(s): 7891

Problem Description

做人要有一身正气,杭电学子都应该如此。比如我们今天的考试就应该做到“诚信”为上。

每次考试的第一个题目总是很简单,今天也不例外,本题是要求输出指定大小的"HDU"字符串,特别地,为了体现“正气”二字,我们要求输出的字符串也是正方形的(行数和列数相等)。

Input

输入的第一行包含一个正整数N(N<=20),表示一共有N组数据,接着是N行数据,每行包含一个正整数M(M<=50),表示一行内有M个“HDU”相连。

Output

输出指定大小的方形字符串,输出格式参见样本数据。

Sample Input

2

1

2

Sample Output

HDU

HDU

HDU

HDUHDU

HDUHDU

HDUHDU

HDUHDU

HDUHDU

HDUHDU

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
//char ch[3]={'H','D','U'};
int t,n,i,j;
scanf("%d",&t);
while (t--)
{
scanf("%d",&n);
for (i=0;i<3*n;i++)
{
for (j=0;j<n;j++)
//printf("%s",ch);
printf("HDU");
printf("\n");
}
}
return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
char ch[4]={'H','D','U','\0'};
int t,n,i,j;
scanf("%d",&t);
while (t--)
{
scanf("%d",&n);
for (i=0;i<3*n;i++)
{
for (j=0;j<n;j++)
printf("%s",ch);
//printf("HDU");
printf("\n");
}
}
return 0;
}


自写字符串要在最后加一个‘0’字节
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: