x图案

X形图案

https://ac.nowcoder.com/acm/contest/67628/1006

题目描述 KiKi学习了循环,BoBo老师给他出了一系列打印图案的练习,该任务是打印用“”组成的X形图案。 本题需要找出每行每列输出的想同处,进行实现 详见代码: #include #include #include #define endl '\n' #define buff ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr); using namespace std; int main() {

ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
	for(int j=1;j<=n;j++)
	{
	if(i==j||i+j==n+1)
	cout<<"*";
	else
	cout<<" ";
	}
	
	cout<<'\n';
}

return 0; }

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务