i need fresh eyes on my code

......
Last edited on
Hi,

Please don't double post - it's ultimately a time waster for those who reply. We could have the same answers being supplied in both topics.

Are all your switch statements are the same?

The best solution would be to have an array of the zip codes, and use a for loop with the switch inside.

You could have a function which takes a zip code (a member of an array) as an argument, then has the switch inside the function.

If you aren't allowed to use either arrays or functions, I would be mystified as to why such restrictions are there.

Btw this : FinalResult = FinalResult + result;

can be written more concisely like this : FinalResult += result;
1
2
3
4
5
6
7
8
std::string digit_to_string( int digit )
{
    static const string[] str = { "||:::", ":::||", "::|:|", "::||:", ":|::|",
                                  ":|:|:", ":||::", "|:::|", "|::|:", "|:|::" } ;

    if( digit < 0 || digit > 9 ) return "" ;
    else return str[digit] ;
}
Topic archived. No new replies allowed.