Input:
輸入包含多組測試數據。第一個整數N(N<=15),N表示組數,每組數據包含兩個整數a,b。a表示一個單位的DNA串的行數,a為奇數且 3<=a<=39。b表示重復度(1<=b<=20)。
Output:
輸出DNA的形狀,每組輸出間有一空行。
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 X
X X
X
X X
X X
X X
X
X X
X X
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n; cin>>n;
int m=1;
for(int a,b;n&&cin>>a>>b;n--)
{ cout<<(m==1?"":"\n");
for(int i=1;i<=b;i++)
{for(int j=1;j<=a/2;j++)
{
cout<<string(j-1,' ');
cout<<'X';
cout<<string(a-2*(j-1)-2,' ');
cout<<'X'<<'\n';
}
cout<<string(a/2,' ');
cout<<'X'<<'\n';
for(int i=a/2;i>1;i--)
{ cout<<string(i-1,' ');
cout<<'X';
cout<<string(a-2*(i-1)-2,' ');
cout<<'X'<<'\n';
}
}
cout<<'X';cout<<string(a-2,' ');
cout<<'X'<<'\n';
m++;
}
}