项目作者: dppss91102

项目描述 :
Data Structure Homework
高级语言: C++
项目地址: git://github.com/dppss91102/DS_HW6_QuickSort_for_Molecules.git


QuickSort for Molecules

Description

  • Given several groups of molecules
    • There may be duplicated molecules
  • Each molecule has
    • A name string (e.g., “caffeine”)
    • A formula string (e.g., “C8H10N4O2”)
    • Molecular mass (can be zero or non-zero)
      • A zero means that your program needs to calculate the mass (Use this periodic table and double is recommended while calculating the mass )
      • A non-zero value means the mass is given
  • Quicksort each group of molecules according to the ascending order of molecular mass
    • Always pick the first entry of each partition as the pivot
    • Do not count swap(array, posi, posj) if posi == posj
  • Print out the molecules and also report the number of swaps used during Quicksort
  • Processing steps example:
    Process

Input

  • Note:
    • The input 1 is the same as sample input/out.
    • All of the molecular masses in input 2~8 are given. (In other words, only input 9 and 10 need to calculate the masses by your own)
      Input

Output

Output

Sample Input
  1. 2
  2. 6
  3. silicon_carbide SiC 0
  4. gallium(III)_nitride GaN 0
  5. caffeine C8H10N4O2 0
  6. silicon(IV)_dioxide SiO2 0
  7. oxygen O 0
  8. hydrogen H2 0
  9. 10
  10. diethyl_ether CH3CH2OCH2CH3 74.00
  11. addcrylonitrile H2C(CH)CN 53.00
  12. amesite Mg2Al(AlSiO5)(OH)4 278.00
  13. ammonium_hexathiocyanoplatinate(IV) (NH4)2[Pt(SCN)6] 579.00
  14. maitotoxin C164H256Na2O68S2 3422.00
  15. barysilate MnPb8(Si2O7)3 2215.00
  16. montmorillonite_(clay) MgNaAl5(Si4O10)3(OH)6 1100.00
  17. uranium_hexafluoride F6U 352.00
  18. stearic_acid CH3(CH2)16COOH 284.00
  19. cobalt(II)_ferricyanide Co3(Fe(CN)6)2 601.00

Sample Output

  1. 2
  2. 6
  3. hydrogen H2 2.00
  4. oxygen O 16.00
  5. silicon_carbide SiC 40.00
  6. silicon(IV)_dioxide SiO2 60.00
  7. gallium(III)_nitride GaN 84.00
  8. caffeine C8H10N4O2 194.00
  9. 5 swaps during qsort
  10. 10
  11. addcrylonitrile H2C(CH)CN 53.00
  12. diethyl_ether CH3CH2OCH2CH3 74.00
  13. amesite Mg2Al(AlSiO5)(OH)4 278.00
  14. stearic_acid CH3(CH2)16COOH 284.00
  15. uranium_hexafluoride F6U 352.00
  16. ammonium_hexathiocyanoplatinate(IV) (NH4)2[Pt(SCN)6] 579.00
  17. cobalt(II)_ferricyanide Co3(Fe(CN)6)2 601.00
  18. montmorillonite_(clay) MgNaAl5(Si4O10)3(OH)6 1100.00
  19. barysilate MnPb8(Si2O7)3 2215.00
  20. maitotoxin C164H256Na2O68S2 3422.00
  21. 8 swaps during qsort