//A program to transpose a general file //Copyright (C) 2005 Daniel Brewer //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either version 2 //of the License, or (at your option) any later version. //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //http://www.gnu.org/copyleft/gpl.html #include #include #include #include using namespace std; int main(int argc, char *argv[]) { vector< vector > array; string filename(argv[1]); //input file string line; ifstream infile(filename.c_str()); if (!infile) { cerr << "File could not be opened" << endl; } else { while (!getline(infile, line).eof()) { istringstream linestream(line); string data; vector row; while (getline(linestream, data, '\t')) { row.push_back(data); } if(row.size()!=0) array.push_back(row); } } //Find maximum size unsigned int max_size=0; for (unsigned int i=0;imax_size) max_size = array[i].size(); } //output file for (unsigned int i=0;i