Advertisement
rajeshinternshala

Untitled

Aug 2nd, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. Camilla's team maintains an archaeology application used primarily by academics, researchers, and field guides. One window of
  2. the application displays a data grid of biographical information about various historical rulers along with archaeological data
  3. thereabout. Each ruler has a regnal name, which is one or more "name parts" (each separated by a single space) followed by a
  4. Roman numeral. Examples of regnal names that may appear on this page are Pedro VII (one "name part") and Alexander Pontus
  5. XV (multiple "name parts"). Note that the Roman numeral portion is always present, and it is always the last contiguous sequence
  6. of characters. Roman numerals are converted into decimal numerals using the standard procedure:
  7.  
  8. The letter I represents 1, V represents 5, X represents 10, L represents 50, C represents 100, D represents 500, and M represents 1000
  9.  
  10. * 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
  11. second, the values are added; for example, the Roman numeral XV is 10 + 5 = 15
  12.  
  13. * 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
  14. subtracted from the value of the second; for example, the Roman numeral IX is 10- 1=9
  15.  
  16. * Asalarger example, the Roman numeral MMCDXLVIII is 1000 + 1000 + (500 - 100) + (50 - 10)+5+1+1+1=2448
  17.  
  18. * Strings such as VVXL, which may be valid under "alternate" translation rules, are invalid Roman numerals under the standard
  19. translation procedure
  20.  
  21. Assume that every regnal name contains a valid Roman numeral as Its regnal number. Implement the following function in the
  22. code editor that sorts the rulers' names ascending, first by regnal number and then by (case-sensitive) regnal name.
  23. /// @param names The unordered collection of regnal names. A complete regnal name may appear more than once
  24. in the
  25.  
  26. /// collection.
  27.  
  28. /// @pre @p names is not empty.
  29.  
  30. /// @returns A new collection containing the same contents as @p name but in ascending sorted order, first
  31. by regnal
  32.  
  33. /// number and then by regnal name.
  34.  
  35. std::vector<std::string> sortRegnalNames(const std::vector<std::string> &names) ;
  36.  
  37. Consider the list of 5 rulers [ Nicholas VIll, Hypapsos XXIV, Garibald Yosef Il, Nicholas C, Michelfranko XXIV }.
  38.  
  39. * In decimal, Nicholas VIll translates into Nicholas 8
  40.  
  41. * In decimal, Hypapsos XXIV translates into Hypapsos 24
  42.  
  43. * In decimal, Garibald Yosef II translates into Garibald Yosef 2
  44. * In decimal, Nicholas C translates into Nicholas 100
  45.  
  46. * In decimal, Michelfranko XXIV translates Into Michelfranko 24
  47.  
  48. The function should therefore return [ Garibald Yosef 2, Nicholas 8, Hypapsos 24, Michelfranko 24, Nicholas 1000 ].
  49.  
  50. use the following function and implement the code:
  51.  
  52. std: :vector<std::string> sortRegnalNames (const std::vector<std::string> &
  53. names) {
  54.  
  55. // implement me!
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement