1412202129-hpu-1006: DNA

Source: Internet
Author: User

1412202129-hpu-1006: DNA

1006: DNA time limit: 1 Sec memory limit: 128 MB
Submitted: 4 solution: 2
[Submit] [Status] [discussion version] Description

Xiaoqiang liked Life Science from an early age. He was always curious about where flowers, birds, and animals came from. Finally, Xiaoqiang went to middle school and came into contact with the holy term DNA. It had a double helix structure. This allows Xiao Qiang, a single tendon, to break his scalp. "If it can be painted, it will be fine." Xiao Qiang shouted. Please help him now

Input

The input contains multiple groups of test data. The first integer N (N <= 15) indicates the number of groups. Each group contains two integers a and B. A indicates the number of lines in a unit of DNA strings. a is an odd number and 3 <= a <= 39. B Indicates the repetition (1 <= B <= 20 ).

Output

The shape of the output DNA. Each set of outputs has a blank line.

Sample input 2 3 1 5 4 sample output X
X
X


X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X solves the problem by observing the output to determine the output format required by the question. Pay attention to two points: 1. There is no extra space after each line. 2. It is not simply a repeated output of a graph, instead, the two small images are connected. Code
# Include
 
  
Int main () {int t; int a, B; int I, j, k; scanf ("% d", & t); while (t --) {scanf ("% d", & a, & B); for (I = 1; I <= B; I ++) {if (I % 2 = 1) // when it is an odd small image, the small image is completely output {for (j = 1; j <=; j ++) {for (k = 1; k <= a; k ++) {if (k = j | k = a-j + 1) printf ("X"); else printf (""); if (j <= a/2 & k = a-j + 1) | (j> a/2 & k = j) break; // avoid unnecessary spaces.} printf ("\ n ");}} else {// when it is the even number of small graphics, the first and end of the small graphics each cut a line and then output for (j = 2; j <= A-1; j ++) {for (k = 1; k <= a; k ++) {if (k = j | k = a-j + 1) printf ("X"); else p Rintf (""); if (j <= a/2 & k = a-j + 1) | (j> a/2 & k = j) break;} printf ("\ n") ;}} if (B % 2 = 0) // if there are a total of even small images, you need to add an end at the end, that is, the last line of the small image {for (I = 1; I <=; I ++) {if (I = 1 | I = a) printf ("X"); else printf ("");} printf ("\ n");} if (t! = 0) printf ("\ n");} return 0 ;}
 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.