/*---------------------------
写一个函数求二维数组的逆.
-------------------------*/
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void show(vector<string>);
vector<string> inverse(vector<string> ivstr)
{
vector<string>::iterator iter;
int num = 0;
for (iter = ivstr.begin(); *iter != "quit"; iter++)
num++;
vector<string> tempstr(++num);
for (int i = 0; i < num-1; i++)
{
tempstr[i] = ivstr[num-i-2];
string temp = tempstr[i];
int l = tempstr[i].length();
for (int j = 0; j < l; j++)
temp[j] = tempstr[i][l-j-1];
for (int j = 0; j < tempstr[i].length(); j++)
tempstr[i][j] = temp[j];
}
tempstr[num-1] = "quit";
return tempstr;
}
void show(vector<string> svstr)
{
vector<string>::iterator iter;
cout << "The char*[] = {"
《C++程序设计语言》7.10_8 一个函数求二维数组的逆
最新推荐文章于 2022-10-25 21:09:09 发布
本文详细介绍了如何使用C++编程语言来实现一个函数,该函数可以对输入的二维数组进行转置操作,即原数组的行变为新数组的列,原数组的列变为新数组的行。内容包括函数的设计思路、实现代码以及可能遇到的问题和解决方法。
摘要由CSDN通过智能技术生成