本文介绍了每个字母表最多29个字符的排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一个程序,将生成一个文本文件,从字符到二十九个字符的字母表的每一个可能的排列。我选择29作为最长的英语单词,每个人都知道是antidisestablishmentismism长度为28个字符。有更长的,但它们主要是非常技术和晦涩。

I'm attempting to write a program that will generate a text file with every possible permutation of the alphabet from one character up to twenty-nine characters. I've chosen 29 as the longest English word that everyone knows is antidisestablishmentarianism which is 28 characters in length. There are longer ones, but they are mainly very technical and obscure.

我意识到这将生成大量的字符串。但是我不知道从哪里开始,甚至不知道这将产生多少组合。

I realise this will generate a huge number of strings. However I've no idea where to start or even how to figure out how many combinations this will generate.

有关PHP解决方案的答案,,C ++或Java(我只熟悉那些,PHP是首选,但可能没有最好的为此我应该想象)。

Answers please for solutions in PHP, Processing, C++ or Java (I'm only familiar with those, PHP is preferred, but probably no the best for this I should imagine).

或者甚至只是伪代码/想法将被赞赏。

Or even just pseudo-code / ideas will be appreciated.

不是为了暴力强迫或任何类似的。我是一个艺术家,虽然有点不知道和我的概念模糊。

Also, before someone says it, this isn't for brute forcing or anything like that. I'm an artist, albeit somewhat unknown and obscure with my concepts.

推荐答案

单词permutation通常意味着每个字母只出现一次,所以不可能生成任何排列更多超过26个字母。无论如何,由于生成的字符串数量太大,你可以使用随机字符串(以下是C代码):

The word "permutation" usually means that each letter appears exactly once, so it would be impossible to generate any permutation with more than 26 letters. Anyway, since the number of generated strings is too big, you can use random strings instead (the following is C code):

char s[30];
int p;
for (;;) // repeat forever: you cannot use a realistic iteration limit anyway
{
    for (p = 0; p < 29; ++p)
        s[p] = 'a' + rand() % 26;
    s[29] = '\0';
    puts(s);
}

这篇关于每个字母表最多29个字符的排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 02:32