Untitled

mail@pastecode.io avatar
unknown
c_cpp
8 days ago
431 B
0
Indexable
Never
std::vector< int > getNumbers()
{
    std::vector< int > result;

    int number = 0;
    int index = 1;

    std::cout << "Enter numbers to put into vector:\n";
    while( true )
    {
        std::cout << "Number " << index << ": ";
        std::cin >> number;
        if( number == 0 )
        {
            break;
        }
        result.push_back( number );

        ++index;
    }

    return result;
}
Leave a Comment