/*------------------------------------------------------- 【程序填空】 --------------------------------------------------------- 题目:下列给定程序中,函数fun的功能是:将N×N矩阵主对角线元素的值与反向对角线 对应位置上元素的值进行交换。 例如:若N=3,有下列矩阵:1 2 3 4 5 6 7 8 9 交换后为:3 2 1 4 5 6 9 8 7 -------------------------------------------------------*/ #include <stdio.h> #define N 4 /***********SPACE***********/ void fun(int 【?】 , int n) { int i,s; /***********SPACE***********/ for(i=0;【?】; i++) { s=t[i][i]; t[i][i]=t[i][n-i-1]; /***********SPACE***********/ t[i][n-1-i]=【?】; } } main() { int t[][N]={21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10}, i, j; printf("\nThe original array:\n"); for(i=0; i<N; i++) { for(j=0; j<N; j++) printf("%d ",t[i][j]); printf("\n"); } fun(t,N); printf("\nThe result is:\n"); for(i=0; i<N; i++) { for(j=0; j<N; j++) printf("%d ",t[i][j]); printf("\n"); } }
时间: 2023-08-09 11:12:30 浏览: 72
答案:
```
void fun(int t[][N], int n) {
int i,s;
for(i=0; i<n; i++) {
s=t[i][i];
t[i][i]=t[i][n-i-1];
t[i][n-1-i]=s;
}
}
```
相关问题
pyinstaller: error: unrecognized arguments: --add-dateimages/*;video/*;music/*-F
看起来你在命令行中使用了 `--add-date` 而不是正确的 `--add-data` 参数。请将命令中的 `--add-date` 修改为 `--add-data`,并且将参数值中的 `date` 改为正确的 `data`,如下所示:
```
pyinstaller --add-data "images/*;video/*;music/*" -F your_script_name.py
```
这个命令将会把 `images`、`video` 和 `music` 文件夹中的所有文件都打包到可执行文件中。`-F` 参数表示将所有依赖项都打包到一个单独的可执行文件中。
请注意,在命令行中使用 `--add-data` 参数时,需要将参数值用双引号括起来,并在路径中使用正斜杠(`/`)而不是反斜杠(`\`),否则 Windows 可能无法正确解析路径。
我想补齐每一行对称的-代码该怎么写--* -*** ***** -*** --*
以下是补齐每一行对称的代码:
```python
n = 5
for i in range(n):
if i < n//2:
print('-'*(n//2-i) + '*'*(2*i+1) + '-'*(n//2-i))
else:
print('-'*(i-n//2) + '*'*(2*(n-i)-1) + '-'*(i-n//2))
```
输出结果为:
```
--*--
-***-
*****
-***-
--*--
```
相关推荐
![xz](https://img-home.csdnimg.cn/images/20210720083646.png)
![java](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)