https://blog.csdn.net/Cream_Cicilian/article/details/114375866?spm=1001.2014.3001.5501
https://blog.csdn.net/Cream_Cicilian/article/details/108962302?spm=1001.2014.3001.5501
https://blog.csdn.net/Cream_Cicilian/article/details/108659285
https://blog.csdn.net/Cream_Cicilian/article/details/124524084?spm=1001.2014.3001.5501
https://www.manongdao.com/article-586585.html
单级文件夹:
#include
#include
#include
int main()
{
std::string prefix = "G:/test/";
if (_access(prefix.c_str(), 0) == -1) //如果文件夹不存在
_mkdir(prefix.c_str()); //则创建
}
多级文件夹,最后一个如果是文件夹的话,需要加上 ‘\’ 或者 ‘/’:
#include
#include
#include
int createDirectory(std::string path)
{
int len = path.length();
char tmpDirPath[256] = { 0 };
for (int i = 0; i < len; i++)
{
tmpDirPath[i] = path[i];
if (tmpDirPath[i] == '\\' || tmpDirPath[i] == '/')
{
if (_access(tmpDirPath, 0) == -1)
{
int ret = _mkdir(tmpDirPath);
if (ret == -1) return ret;
}
}
}
return 0;
}
https://blog.csdn.net/Cream_Cicilian/article/details/122362436?spm=1001.2014.3001.5501
https://blog.csdn.net/Cream_Cicilian/article/details/122370824?spm=1001.2014.3001.5501
https://blog.csdn.net/Cream_Cicilian/article/details/115347354?spm=1001.2014.3001.5501
#include
#include
using namespace std;
using namespace std::experimental::filesystem;
int main() {
path str("D:\\WWY\\1");
if (!exists(str)) //必须先检测目录是否存在才能使用文件入口.
return 1;
directory_entry entry(str); //文件入口
if (entry.status().type() == file_type::directory) //这里用了C++11的强枚举类型
cout << "该路径是一个目录" << endl;
directory_iterator list(str); //文件入口容器
for (auto& it : list)
cout << it.path().filename() << endl; //通过文件入口(it)获取path对象,再得到path对象的文件名,将之输出
system("pause");
return 0;
}
// random_shuffle_demo.cpp : 定义控制台应用程序的入口点。
//
#include
#include
#include
#include
using namespace std;
int main()
{
vector<int> vs;
vs.push_back(1);
vs.push_back(2);
vs.push_back(3);
vs.push_back(4);
vs.push_back(5);
vs.push_back(6);
vs.push_back(7);
random_shuffle(vs.begin(), vs.end()); /* 打乱顺序 */
for (int i = 0; i < 7; i++)
cout << vs[i] << " "; /* 显示打乱顺序后的元素 */
}
// random_shuffle_demo.cpp : 定义控制台应用程序的入口点。
//
#include
#include
#include
#include
#include
using namespace std;
int main()
{
std::map<int, string> mymap;
// 插入单个值
mymap.insert(std::pair<int, string>(1, "100"));
mymap.insert(std::pair<int, string>(2, "200"));
mymap.insert(std::pair<int, string>(3, "300"));
mymap.insert(std::pair<int, string>(4, "400"));
mymap.insert(std::pair<int, string>(5, "500"));
mymap.insert(std::pair<int, string>(6, "600"));
mymap.insert(std::pair<int, string>(7, "700"));
mymap.insert(std::pair<int, string>(8, "00"));
vector<int> vs;
vs.push_back(1);
vs.push_back(2);
vs.push_back(3);
vs.push_back(4);
vs.push_back(5);
vs.push_back(6);
vs.push_back(7);
random_shuffle(vs.begin(), vs.end()); /* 打乱顺序 */
for (int i = 0; i < 7; i++)
cout << vs[i] << " "; /* 显示打乱顺序后的元素 */
//cout << mymap.at(3) << endl;
vector<string> vs_rusalt;
for (int k = 0; k < 7; k++)
{
int tmp =0;
tmp = vs[k];
string temp = mymap[tmp];
cout << temp << " ";
}
/*for (int i = 0; i < 7; i++)
cout << vs_rusalt[i] << " "; /* 显示打乱顺序后的元素 */
}
// random_shuffle_demo.cpp : 定义控制台应用程序的入口点。
//
#include
#include
#include
#include
#include
using namespace std;
int main()
{
std::map<int, string> mymap;
// 插入单个值
mymap.insert(std::pair<int, string>(1, "100"));
mymap.insert(std::pair<int, string>(2, "200"));
mymap.insert(std::pair<int, string>(3, "300"));
mymap.insert(std::pair<int, string>(4, "400"));
mymap.insert(std::pair<int, string>(5, "500"));
mymap.insert(std::pair<int, string>(6, "600"));
mymap.insert(std::pair<int, string>(7, "700"));
mymap.insert(std::pair<int, string>(8, "00"));
vector<int> vs;
vs.push_back(1);
vs.push_back(2);
vs.push_back(3);
vs.push_back(4);
vs.push_back(5);
vs.push_back(6);
vs.push_back(7);
random_shuffle(vs.begin(), vs.end()); /* 打乱顺序 */
for (int i = 0; i < 7; i++)
cout << vs[i] << " "; /* 显示打乱顺序后的元素 */
//cout << mymap.at(3) << endl;
vector<string> vs_rusalt;
for (int k = 0; k < 7; k++)
{
int tmp =0;
tmp = vs[k];
string temp = mymap[tmp];
cout << temp << " ";
}
/*for (int i = 0; i < 7; i++)
cout << vs_rusalt[i] << " "; /* 显示打乱顺序后的元素 */
}
https://blog.csdn.net/u011857683/article/details/81058622
bool FindKeyWord(string s, string keyWord) {
string::size_type idx;
idx = s.find(keyWord);//在a中查找b.
if (idx != string::npos) {
return 1;
}
else {
return 0;
}
}
/*
提取字符串中的数字
*/
string FindNumber(string s) {
int i = 0, j = 0;
int len_s = s.size();
vector <int> a;
while (i < len_s)
{
if (s[i] >= '0'&& s[i] <= '9')
{
j = i;
int len = 0;
while (s[i] >= '0'&& s[i] <= '9')
{
i++;
len++;
}
string s0 = s.substr(j, len);//获取子串
int num = 0;//数字字符串转换为整型数字
stringstream s1(s0);
s1 >> num;
a.push_back(num);
}
else
{
i++;
}
}
//for (int w = 0; w < a.size(); w++) {
// std::cout << a[w] << endl;
//}
stringstream ss;
string str;
copy(a.begin(), a.end(), ostream_iterator<int>(ss, ""));
str = ss.str();
return str;
}