Although you're overdoing it a bit. I'd write it like this:
Whitespace placement is a matter of taste, really, but I don't know anyone who thinks that removing as much as the language allows is a good idea.Code:
for (VI it1 = st[temp.v1].begin(); it1 != st[temp.v1].end(); it1++)
Of course, you get a more effective readability improvement by factoring out that horrible nested indexing. Since you're using <array> I'm going to assume your compiler supports auto.
That still leaves your horrid naming. What is up with this?Code:
for (c = 10; (c * c) < 1000; c++)
temp.v1 = itotr(c * c);
auto& a1 = st[temp.v1];
for (VI it1 = a1.begin(); it1 != a1.end(); it1++)
auto& a2 = st[temp.v1];
for(VI it2 = a2.begin(); it2 != st[temp.v1].end(); it2++)
Seriously? Is your need to save three keystrokes per use of this class so big that you can't just call the class Triad? It's members are called disp() (What's wrong with display()? Or print(), which is shorter, and closer to typical computer terminology?), v1, v2, and v3. What are v1, v2 and v3? For that matter, what is a triad?Code:
class Tr //triad
You're basically confusing comments with names. In the above snippet, the comment should be the name, and the actual comment should say something like, "Given a three-digit number, return an array containing the three digits."Code:
itotr // int to triad row
Then add an assertion to the function that validates that the number is actually in the expected range.
Why is storage not called "results"? Every variable stores something. The special thing about this one is that it stores the actual results of your program.
What is mc? Inspection of your program tells me that it is the result count. Call it resultCount. And then remove it, because you realize that it is always equal to results.size().
Typedefs would also help. A typedef of array<int, 3> to Row or TriadRow would go a long way towards making the type vector<array<int, 3>> palatable. Of course, giving st a name that indicates what it is (a map from first digit to possible rows, try "possibleRowsByFirstDigit" or "rowsStartingWith") would go even further.
Basically, your code is extremely cryptic because you want it to be compact. That's not a good habit.