Are you still stuck?
try doing something like this. First you'll need these libraries:
#include<sstream> #include<string>You now need a new NumToString function, which I also just posted on the forum
std::string NumToString(double num) { std::stringstream s; s << num; return s.str(); }Then you want to create a nice list of your data, but remember the largest array you find, so create:
std::list<std::string> rows; std::string tmp; int maxlen=0;Now everywhere you're using printf, replace this with the construction of the string, then when you're finished with that line, push it into the list container and not the max length of the line. Heres the first second line for ya:
tmp=NumToString(1)<<" "<<NumToString(2)<<" "<<NumToString(1); maxlen=max(maxlen,tmp.length()); rows.push_back(tmp);Then when you're done creating as many lines as you want, you need to cycle through the list and output with your printf, only you'll be wanting to push in some blanks to ensure everything is central. --- On a side note, this looks very much like homework. I don't do other peoples homework, so this is all the help you'll get from me :)
Login