码迷,mamicode.com
首页 > 其他好文 > 详细

std

时间:2019-03-04 17:22:03      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:保留   pen   style   file   namespace   pac   adl   cout   ace   

 

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;
    }
}

 

 

std

标签:保留   pen   style   file   namespace   pac   adl   cout   ace   

原文地址:https://www.cnblogs.com/fangjj215/p/10471643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!