Sorting alphabetically

前端 未结 1 654
Happy的楠姐
Happy的楠姐 2021-01-26 05:14

Here is my code...What would be the best way to sort names alphabetically?

#include 
#include 
#include 
using name         


        
1条回答
  •  情歌与酒
    2021-01-26 06:10

    The standard way is to use std::sort:

    #include 
    
    // ...
    
    std::sort(sname, sname + StudentNum);
    

    std::sort uses operator< by default, which actually does an alphabetical comparison for strings.

    EDIT: Indeed, it should be StudentNum instead of 25.

    0 讨论(0)
提交回复
热议问题