List of all available Websheets
Viewing cpp/cs104/stl/zip_sort by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | Read zip code integers from <tt>cin</tt>. Then output them in sorted order. <p> Look up the documentation for <a href="http://www.cplusplus.com/reference/algorithm/sort/"><tt>std::sort</tt></a> and see if you can figure out how to use it. |
Remarks Comments, history, license, etc. | Copied from problem cpp/cs104/stl/zip_map (author: redekopp@usc.edu) |
Engine | |
Template / Reference solution |
using namespace std; int main(int argc, char *argv[]) { vector<int> all_zips; int zipCode; while(cin >> zipCode){ all_zips.push_back(zipCode); } cout << "Sorted zip code, occurrence table (by zip code)" << endl; // Sort the all_zips vector \[ REDACTED ]\ // write a for loop to print out the sorted zip codes \[ REDACTED ]\ { cout << *it << endl; } return 0; } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [{"stdin":"90018 90018 90007 90018 90089 90007 90006"}] |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.