Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Camilla's team maintains an archaeology application used primarily by academics, researchers, and field guides. One window of
- the application displays a data grid of biographical information about various historical rulers along with archaeological data
- thereabout. Each ruler has a regnal name, which is one or more "name parts" (each separated by a single space) followed by a
- Roman numeral. Examples of regnal names that may appear on this page are Pedro VII (one "name part") and Alexander Pontus
- XV (multiple "name parts"). Note that the Roman numeral portion is always present, and it is always the last contiguous sequence
- of characters. Roman numerals are converted into decimal numerals using the standard procedure:
- The letter I represents 1, V represents 5, X represents 10, L represents 50, C represents 100, D represents 500, and M represents 1000
- * When two letters appear next to one another and the first is the same as the second, or represents a larger decimal value that the
- second, the values are added; for example, the Roman numeral XV is 10 + 5 = 15
- * When two letters appear next to one another and the first represents a smaller decimal value than the second, the value of the first Is
- subtracted from the value of the second; for example, the Roman numeral IX is 10- 1=9
- * Asalarger example, the Roman numeral MMCDXLVIII is 1000 + 1000 + (500 - 100) + (50 - 10)+5+1+1+1=2448
- * Strings such as VVXL, which may be valid under "alternate" translation rules, are invalid Roman numerals under the standard
- translation procedure
- Assume that every regnal name contains a valid Roman numeral as Its regnal number. Implement the following function in the
- code editor that sorts the rulers' names ascending, first by regnal number and then by (case-sensitive) regnal name.
- /// @param names The unordered collection of regnal names. A complete regnal name may appear more than once
- in the
- /// collection.
- /// @pre @p names is not empty.
- /// @returns A new collection containing the same contents as @p name but in ascending sorted order, first
- by regnal
- /// number and then by regnal name.
- std::vector<std::string> sortRegnalNames(const std::vector<std::string> &names) ;
- Consider the list of 5 rulers [ Nicholas VIll, Hypapsos XXIV, Garibald Yosef Il, Nicholas C, Michelfranko XXIV }.
- * In decimal, Nicholas VIll translates into Nicholas 8
- * In decimal, Hypapsos XXIV translates into Hypapsos 24
- * In decimal, Garibald Yosef II translates into Garibald Yosef 2
- * In decimal, Nicholas C translates into Nicholas 100
- * In decimal, Michelfranko XXIV translates Into Michelfranko 24
- The function should therefore return [ Garibald Yosef 2, Nicholas 8, Hypapsos 24, Michelfranko 24, Nicholas 1000 ].
- use the following function and implement the code:
- std: :vector<std::string> sortRegnalNames (const std::vector<std::string> &
- names) {
- // implement me!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement