希望能实现用C++实现一个字一个字输出一段话(如果不能,Python,C语言也可以),但是不能引用windows.h等,因为我是华为手机端
实现如下效果
第一秒:你
第二秒:你好
第三秒:你好世
第四秒:你好世界
时间间隔可以更改,附:我可以使用sleep
感谢!
兄弟,看看我的标准答案,你要的 C++。
#include <iostream>
#include <thread>
using namespace std;
int main(int, char **)
{
locale::global(locale(""));
wstring hello = L"你好世界!";
for (size_t i = 1; i <= hello.length(); ++i)
{
this_thread::sleep_for(std::chrono::seconds(1));
wcout << hello.substr(0, i) << endl;
}
}
#include<bits/stdc++.h>
using namespace std;
void second()
{
unsigned long long i;
for(i=1;i<=401005000;i++)
{
}
}
int main()
{
cout<<"你"<<endl;
second();
cout<<"你好"<<endl;
second();
cout<<"你好世"<<endl;
second();
cout<<"你好世界"<<endl;
second();
}
虽不是刚好4s,但在其左右:
这里的string你可以根据自己的需要在双引号中填写,sleep的时间也可以根据需求在括号中填写单位为秒
import sleep
string = "你好世界"
for i in len(string):
print(string[:i+1])
sleep(1)
问题我自己解决了,回答没有合适的(但是不错),随机采纳一个