std

1.vector delete

    std::vector<string> strs;
    std::vector<string> strs;
    strs.push_back("asda1");
    strs.push_back("asda2");
    strs.push_back("asda3");
    strs.push_back("asda4");
    
    strs.erase(strs.begin() + 2);
    for (string s : strs)
    {
        mc::print(s);
    }

2.read file

void mc::readLines(std::string f, std::vector<std::string>& lines)
{
    std::ifstream ifile(f);
    std::string line;
    while (std::getline(ifile, line)) {
        lines.push_back(line);
    }
    ifile.close();
}

3.打印保留有效数字

#include <iostream>
#include <iomanip>

namespace mc
{
    template <typename T>
    void print(T a)
    {
        std::cout<< std::setprecision(10) << a << std::endl;
    }
}

 

猜你喜欢

转载自www.cnblogs.com/fangjj215/p/10471643.html
std