解题思路:
注意事项:
参考代码:
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int num;
int a,b;
cin>>num;
for(int i=0;i<num;i++)
{
cin>>a>>b;
for(int j=0;j<b;j++) //重复度问题
{
for(int t=1;t<a;t++) //每行打印
{
for(int s=1;s<=a;s++)
{
if(s==t||s==a+1-t)
{
cout<<"X";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
}
for(int s=1;s<=a;s++) //打印最后一行
{
if(s==1||s==a)
{
cout<<"X";
}
else
{
cout<<" ";
}
}
cout<<endl;
cout<<endl;
getchar();
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:633 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:543 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:787 |
1908题解浏览:640 |
数字游戏 (C++代码)浏览:1185 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:588 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:537 |
1197求助浏览:631 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:508 |
多输入输出练习2 (C语言代码)浏览:1657 |