Questions about tasks! And view code, please ^^
Well, this code is the first code I've actually made on my own, by my own thinking and that's kinda advanced and loads of thinking (For me!) so it's an achievement for me ^^ Dunno if you peeps remember the feeling and maybe the code that was your first very own, working program :P anyways here's the code:
Code:
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using std::string; using std::cout;
using std::cin; using std::vector;
using std::endl; using std::sort;
int main(){
cout<<"Please input a sentence: ";
vector<string> inpVecStr;
string input;
while(cin>> input)
inpVecStr.push_back(input);
//Now the inputted sentence is in inpVecStr
vector<string> indexedVec;
{string inputtedStr;
for(vector<string>::size_type i = 0; i != inpVecStr.size(); ++i)
inputtedStr += inpVecStr[i] + " ";
inputtedStr += "\n";
indexedVec.push_back(inputtedStr);
} //inputtedStr is deleted here
for(vector<string>::size_type i = 0; i != inpVecStr.size() - 1; ++i){
vector<string>::const_iterator it = inpVecStr.begin();
inpVecStr.push_back(*it);
inpVecStr.erase(inpVecStr.begin());
string tmpString;
for(vector<string>::size_type j = 0; j != inpVecStr.size(); ++j)
tmpString += inpVecStr[j] + " ";
tmpString += "\n";
indexedVec.push_back(tmpString);
}
for(vector<string>::size_type i = 0; i != indexedVec.size(); ++i)
cout<< indexedVec[i];
return 0;
}
Well, I'd like you peeps to check for stuff that could be improved, if you have the time, just so that I can learn of it, also I'm not very good at using comments, sorry, but they might be wrong, as in, I typed one in there 'cause I think it works like that, so if it doesn't please correct me :P (it's the one, //inputtedStr is deleted here) ;)
Also, I have some questions about my task :P
Design and implement a program to produce a permuted index. A what? :S
2. Sort the rotations.
3. Unrotate and write the permuted index, which involves finding the separator, putting
the phrase back together, and writing it properly formatted. What am I supposed to sort o.O? and the 3rd just makes no sense :P
Sorry I ain't English :P