|
@@ -1,37 +1,43 @@
|
|
|
-#include <iostream>
|
|
|
+# include <iostream>
|
|
|
+# include <ctime>
|
|
|
+# include <cstdlib>
|
|
|
+# include <string>
|
|
|
|
|
|
-using namespace std;
|
|
|
+# define MAJ_JUMP int('A') - int('a')
|
|
|
|
|
|
-string giveName(unsigned int size = 7);
|
|
|
+// Génère un nom de minion aléatoirement.
|
|
|
|
|
|
-int main() {
|
|
|
- cout << "Minion's name generator!" << endl;
|
|
|
- cout << "provided by Jovian Hersemeule" << endl << endl;
|
|
|
+using namespace std ;
|
|
|
|
|
|
- srand(time(0));
|
|
|
+string create( int mini = 2, int maxi = 6 )
|
|
|
+{
|
|
|
+ string rep("");
|
|
|
|
|
|
- for (int k(0); k < 5; k++) {
|
|
|
- cout << "Minion " << k + 1 << " : " << giveName() << endl;
|
|
|
- }
|
|
|
+ string voy("aeiouy");
|
|
|
+ string cons("bcdfghjklmnpqrstvwxy");
|
|
|
|
|
|
- return 0;
|
|
|
-}
|
|
|
+ int n( rand() % (maxi - mini) + mini );
|
|
|
+ int k;
|
|
|
+
|
|
|
+ for ( int i(0); i < n; i ++ )
|
|
|
+ {
|
|
|
+ k = rand() % cons.size();
|
|
|
+ rep += cons[k];
|
|
|
|
|
|
-string giveName(unsigned int size) {
|
|
|
- string voyel("aeiou");
|
|
|
- string conson("bcdfghjklmnpqrstvwxyz");
|
|
|
+ k = rand() % voy.size();
|
|
|
+ rep += voy[k];
|
|
|
+ }
|
|
|
|
|
|
- string newName;
|
|
|
+ rep[0] = char( int(rep[0]) + MAJ_JUMP );
|
|
|
|
|
|
- for (int k(0); k < size; k++) {
|
|
|
- if (k % 2) { // Voyelle
|
|
|
- newName.append(1, voyel[rand() % voyel.length()]);
|
|
|
- } else { // Consonne
|
|
|
- newName.append(1, conson[rand() % conson.length()]);
|
|
|
- }
|
|
|
- }
|
|
|
+ return rep;
|
|
|
+}
|
|
|
|
|
|
- newName[0] = toupper(newName[0]);
|
|
|
+int main()
|
|
|
+{
|
|
|
+ srand( time(0) );
|
|
|
|
|
|
- return newName;
|
|
|
-}
|
|
|
+ cout << create() << endl ;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|