for m*n*k unequal - col - multi array still works ; pick one from a1 a2 a3


#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
void getShowdowlist(vector<int> rwlst, vector<int> &slst, int i){
	int k = 0;

	while (i)
	{
		slst[k] = (i%rwlst[k]);
		i = i / rwlst[k];
		k++;
	}
}
void get(vector<vector<int>> aa){
	vector<int> rowlist;
	vector<int> shadowlist;
	for (int i = 0; i < aa.size(); ++i){
		rowlist.push_back(aa[i].size());
	}
	int sum = 1;
	for (int i = 0; i < rowlist.size(); ++i){
		sum *= rowlist[i];
	}

	for (int j = 0; j < sum; ++j){

		shadowlist.clear();
		for (int j1 = 0; j1 < rowlist.size(); ++j1){
			shadowlist.push_back(0);
		}

		getShowdowlist(rowlist, shadowlist, j);
		
		for (int j = 0; j < shadowlist.size(); ++j){
		//	cout << shadowlist[j];
		}
		cout << j << " => ";
		for (int t = 0; t < aa.size(); ++t){
			//for (int z = 0; z < shadowlist.size(); ++z){
				//cout << t << " x " << z << endl;
				cout << aa[t][shadowlist[t]] << " ";
			//}
			
		}
		cout << endl;
		shadowlist.clear();
		for (int j = 0; j < rowlist.size(); ++j){
			shadowlist.push_back(0);
		}
		cout << endl;
	}
}
int main(int argc, char *argv[])
{
	std::vector<vector<int>> aa;
	vector<int> a1 = { 1, 2, 3 };
	vector<int> a2 = { 4, 5 };
	vector<int> a3 = { 7, 9, 10, 11,19};
	aa.push_back(a1);
	aa.push_back(a2);
	aa.push_back(a3);
	get(aa);
	system("PAUSE");
	return EXIT_SUCCESS;
}
 
 
@SJ, California , thanks for Qj ~



注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com