6个字符串装入vector容器中,采用某一种STL排序算法,对这6个字符串进行排序后输出

1个回答

  • #include

    #include

    #include

    #include

    #include

    int main(int argc, char *argv[])

    {

    std::vector s;

    //将字符串东方压入数组

    s.push_back("asayjk");

    s.push_back("bhjresaf");

    s.push_back("cebnmr");

    s.push_back("dttzlo");

    s.push_back("cqwsw");

    s.push_back("actrfs");

    //对字符串数组进行排序

    std::sort(s.begin(),s.end());

    //输出

    std::copy(s.begin(),s.end(),std::ostream_iterator(std::cout,"n"));

    return 0;

    }