我想创建一个程序,生成一系列从1到1000的carachtere,包括数字和字母。例如:0001 0002 0003 0004 0005 0006 0007 0008 0009 000a 000b 000c 000d 000e 000f 000f ... 000z 0010 00011 ...
只需将您的数字放在一个字符串中并循环遍历它们
#include <string>
#include <iostream>
const std::string digits = "0123456789abcdefghijklmnopqrstuvwxyz";
int main()
{
for (auto a : digits)
{
for (auto b : digits)
{
for (auto c : digits)
{
for (auto d : digits)
{
std::cout << a << b << c << d << '\n';
if (a == '1') // stop at 1000
return 0;
}
}
}
}
}
四位数,四个循环。把你喜欢的任何字母或数字放在数字中。如果您愿意,可以添加停止条件。
有更复杂的方法可以做到这一点,但上述内容应该适合你。