#include <iostream>
#include <vector>
// using namespace std; // *** avoid

/*void*/ int main() // *** main must return int
{
    const int a[] = { 1, 2, 2, -2, 2, -2, 3, -2, 3, -3, -2 };
    const int N = sizeof(a) / sizeof( a[0] ) ;

    // find the smallest and biggest elements
    int smallest = a[0] ;
    int biggest = a[0] ;
    for( int i = 1 ; i < N ; ++i )
    {
        if( a[i] < smallest ) smallest = a[i] ;
        if( a[i] > biggest ) biggest = a[i] ;
    }

    // we can't use a c-style array for f; size is not known at compile time
    // http://w...content-available-to-author-only...a.com/tutorials/vectors.html
    std::vector<int> f( (biggest-smallest) + 1 ) ;
    for( int i = 0 ; i < N ; ++i ) ++f[ a[i] - smallest ] ;

    for( std::size_t i = 0 ; i < f.size() ; ++i )
    {
        const int count = f[i] ;
        if( count > 0 )
        {
            const int n = i + smallest ;
            std::cout << n << " appears " << count << " time" ;
            if( count > 1 ) std::cout << 's' ;
            std::cout << ".\n" ;
        }
    }
}
