<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ressources]]></title><description><![CDATA[Ressources]]></description><link>https://melinyel.net/category/166</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 03:55:15 GMT</lastBuildDate><atom:link href="https://melinyel.net/category/166.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Sep 2014 17:51:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Générateur de combinaisons aléatoires]]></title><description><![CDATA[&lt;p&gt;Bonjour, je vous partage un de mes tout premiers codes, que j'avais fais pour m'entrainer à la base.&lt;br/&gt;
Celui-ci n'est pas forcément optimisé, c'est pas nécessaire de le faire ceci dit.&lt;br/&gt;&lt;br/&gt;
Ce code va simplement générer toutes les combinaisons aléatoire jusqu'à 5 caractères, ce qui représente 62^5 entrées, dans un fichier texte.&lt;/p&gt;
&lt;p&gt;Je n'ai pas fais plus car ça prend déjà une dizaine de giga et beaucoup d'heures pour aller jusqu'à là.  &lt;/p&gt;
&lt;p&gt;
Vous devez simplement créer dans le dossier du code source texte les fichiers texte suivants : 1.txt  / 2.txt / 3.txt / 4.txt / 5.txt&lt;/p&gt;
&lt;pre class="ipsCode prettyprint lang-nocode"&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
using namespace std;
int main()
{
string caractere[62] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
string combinaison;
int car1, car2, car3, car4, car5, car6, car7;
ofstream fichier1("1.txt", ios::out | ios::trunc);
if(fichier1)
{
    //Calcul de toutes les combinaisons à 1 caractères : 62
    for(car1=0; car1!=62; car1++)
    {
        combinaison = caractere[car1];
        cout &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
        fichier1 &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
    }
    fichier1.close();
}
else
{
    cout &amp;lt;&amp;lt; "Impossible d'ouvrir le fichier !" &amp;lt;&amp;lt; endl;
}

ofstream fichier2("2.txt", ios::out | ios::trunc);
if(fichier2)
{
    //Calcul de toutes les combinaisons à 2 caractères : 62²
    for(car1=0; car1!=62; car1++)
    {
        for(car2=0; car2!=62; car2++)
        {
        combinaison = caractere[car1] + caractere[car2];
        cout &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
        fichier2 &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
        }
    }
    fichier2.close();
}
else
{
    cout &amp;lt;&amp;lt; "Impossible d'ouvrir le fichier !" &amp;lt;&amp;lt; endl;
}


ofstream fichier3("3.txt", ios::out | ios::trunc);
if(fichier3)
{
    //Calcul de toutes les combinaisons à 3 caractères : 62^3
    for(car1=0; car1!=62; car1++)
    {
        for(car2=0; car2!=62; car2++)
        {
            for(car3=0; car3!=62; car3++)
            {
            combinaison = caractere[car1] + caractere[car2] + caractere[car3];
            cout &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
            fichier3 &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
            }
        }
    }
    fichier3.close();
}
else
{
    cout &amp;lt;&amp;lt; "Impossible d'ouvrir le fichier !" &amp;lt;&amp;lt; endl;
}

ofstream fichier4("4.txt", ios::out | ios::trunc);
if(fichier4)
{
    //Calcul de toutes les combinaisons à 4 caractères : 62^4
    for(car1=0; car1!=62; car1++)
    {
        for(car2=0; car2!=62; car2++)
        {
            for(car3=0; car3!=62; car3++)
            {
                for(car4=0; car4!=62; car4++)
                {
                combinaison = caractere[car1] + caractere[car2] + caractere[car3] + caractere[car4];
                cout &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
                fichier4 &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
                }
            }
        }
    }
    fichier4.close();
}
else
{
    cout &amp;lt;&amp;lt; "Impossible d'ouvrir le fichier !" &amp;lt;&amp;lt; endl;
}


ofstream fichier5("5.txt", ios::out | ios::trunc);
if(fichier5)
{
    //Calcul de toutes les combinaisons à 5 caractères : 62^5
    for(car1=0; car1!=62; car1++)
    {
        for(car2=0; car2!=62; car2++)
        {
            for(car3=0; car3!=62; car3++)
            {
                for(car4=0; car4!=62; car4++)
                {
                    for(car5=0; car5!=62; car5++)
                    {
                        combinaison = caractere[car1] + caractere[car2] + caractere[car3] + caractere[car4] + caractere[car5];
                        cout &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
                        fichier5 &amp;lt;&amp;lt; combinaison &amp;lt;&amp;lt; endl;
                    }
                }
            }
        }
    }
    fichier5.close();
}
else
{
    cout &amp;lt;&amp;lt; "Impossible d'ouvrir le fichier !" &amp;lt;&amp;lt; endl;
}

}
&lt;/pre&gt;
&lt;p&gt;Ca remonte loin, ce bout de code. A l'époque ça m'avait beaucoup amusé.&lt;br/&gt;
Il peut servir d'exemple si vous souhaitez faire de l'ouverture/écriture de fichier.&lt;/p&gt;
]]></description><link>https://melinyel.net/topic/1080/générateur-de-combinaisons-aléatoires</link><guid isPermaLink="true">https://melinyel.net/topic/1080/générateur-de-combinaisons-aléatoires</guid><dc:creator><![CDATA[Azad]]></dc:creator><pubDate>Thu, 11 Sep 2014 17:51:44 GMT</pubDate></item></channel></rss>