最佳答案
好吧,我不会只是做你的作业,但这里有一些代码,你可以考虑将其作为提示来帮助你入门。
#include <stdio.h>
void printRelevant(int n)
{
for(int r=0; r<n; ++r)
{
for(int c=0; c<n; ++c)
{
if (r < n/2 || c > r || c < n-r-1)
{
printf("-");
}
else
{
printf("X");
}
}
printf("\n");
}
}
int main(void) {
printRelevant(17);
return 0;
}
输出:
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
--------X--------
-------XXX-------
------XXXXX------
-----XXXXXXX-----
----XXXXXXXXX----
---XXXXXXXXXXX---
--XXXXXXXXXXXXX--
-XXXXXXXXXXXXXXX-
XXXXXXXXXXXXXXXXX
关于c - 求 C 中某些矩阵元素的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52760657/