qt二维数组进行转置
时间: 2024-01-12 20:21:53 浏览: 143
yolov3 在 Open Images 数据集上预训练了 SPP 权重以及配置文件.zip
以下是使用Qt进行二维数组转置的示例代码:
```cpp
#include <iostream>
#include <QVector>
int main() {
QVector<QVector<int>> arr = {{1, 2, 3}, {4, 5, 6}};
QVector<QVector<int>> arr1(arr[0].size(), QVector<int>(arr.size()));
// 转置前遍历
std::cout << "转置前:" << std::endl;
for (int i = 0; i < arr.size(); i++) {
for (int j = 0; j < arr[i].size(); j++) {
std::cout << arr[i][j] << "\t";
}
std::cout << std::endl;
}
// 进行转置
for (int i = 0; i < arr.size(); i++) {
for (int j = 0; j < arr[i].size(); j++) {
arr1[j][i] = arr[i][j]; }
}
// 转置后遍历
std::cout << "转置后:" << std::endl; for (int i = 0; i < arr1.size(); i++) {
for (int j = 0; j < arr1[i].size(); j++) {
std::cout << arr1[i][j] << "\t";
}
std::cout << std::endl;
}
return 0;
}
```
阅读全文