题解 | #X形图案#
X形图案
https://www.nowcoder.com/practice/83d6afe3018e44539c51265165806ee4
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
for (int i = 0; i < n; i++) {
for(int j =0; j< n;j++)
{
if(j == i || j == n - i -1) cout <<'*'; //当出现对角线元素时,输出*,其他情况输出空格
else cout <<' ';
}
cout << endl;
}
}
return 0;
}
// 64 位输出请用 printf("%lld")
查看9道真题和解析