/*---------------------------
写一个函数求二维数组的逆.
-------------------------*/
#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*[] = {";
for (iter = svstr.begin(); iter != svstr.end(); iter++)
if (*iter != "quit")
cout << *iter << ", ";
el
《C++程序设计语言》7.10_8 一个函数求二维数组的逆
最新推荐文章于 2024-10-21 20:02:42 发布
本文详细介绍了如何使用C++编程语言来实现一个函数,该函数可以对输入的二维数组进行转置操作,即原数组的行变为新数组的列,原数组的列变为新数组的行。内容包括函数的设计思路、实现代码以及可能遇到的问题和解决方法。


1026

被折叠的 条评论
为什么被折叠?



