#include <iostream>
#include <random>
#include <string>
#include <chrono>
using namespace std;
string string_maker5000(int length)
{
unsigned seed = std::chrono::steady_clock::now().time_since_epoch().count();
default_random_engine e(seed);
string stringcheese;
for (int i = 1; i <= length; i++)
{
uniform_int_distribution<int> distr(0, 1);
int n = distr(e);
stringcheese = ": ";
stringcheese += n;
}
return stringcheese;
}
int main()
{
string yee = string_maker5000(5);
cout << yee << endl;
}
每当我运行程序时,它不是输出 1 和 0,而是输出我认为的 1 的问号框,并且它似乎将 0 输出为空白。我不太确定。让我觉得它是 utf 或其他类型的问题。
整数0
和1
与数字(字符)'0'
和'1'
. 试试这个
stringcheese += n + '0';
通过将整数添加到零位,您可以将整数转换为所需的字符。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句