#include <bits/stdc++.h>
#include <thread>
#include <mutex>
#include <condition_variable>
using namespace std;
void countdown(int count) {
// 从count开始倒数,每次间隔1秒
for (int i = count; i > 0; --i) {
cout << i << "秒后结束。" << endl;
// 当前线程睡眠1秒
this_thread::sleep_for(chrono::seconds(1));
}
}
void output_text() {
// 定义字符串,遍历输出每个字符
string text = "这是一些文本。";
for (char c : text) {
// 输出单个字符并刷新输出流,每次间隔200毫秒
cout << c << flush;
this_thread::sleep_for(chrono::milliseconds(200));
}
}
int main() {
// 定义两条线程并启动它们
thread t1(countdown, 10);
thread t2(output_text);
// 等待线程执行完毕
t1.join();
t2.join();
// 输出完毕后返回0
cout << "倒计时和文本输出已完成。" << endl;
return 0;
}
这是我写的代码 报错:32 2 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\c++0x_warning.h [Error] #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. 是直接调到warning文件保存的,有没有大佬帮忙解决一下啊,我是用dev 5.11的