注意:(每组输出有一个空行)
cout << endl;
cout << endl;
参考代码:
#include<iostream>
using namespace std;
void show(int a,int b)
{
for (int i = 0; i < b; i++)
{
for (int j = 0; j < a - 1; j++)
{
for (int k = 0; k < a; k++)
{
if (k == j || k+ j == (a - 1))
cout << "X";
else
{
cout << " ";
}
}
cout << endl;
}
}
for (int i = 0; i < a; i++)
{
if (i == 0 || i == (a - 1))
{
cout << "X";
}
else
{
cout << " ";
}
}
cout << endl;
cout << endl;
}
int main(){
int n,a,b;
cin >> n;
while (n--)
{
cin >> a >> b;
show(a, b);
}
}
0.0分
0 人评分