Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Release v2
Browse files Browse the repository at this point in the history
* Added random function
* some code optimization
  • Loading branch information
sa-shiro committed Oct 13, 2019
1 parent b055955 commit 8bbc50b
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 41 deletions.
Binary file modified .vs/RandomNameGenerator/v16/.suo
Binary file not shown.
Binary file modified .vs/RandomNameGenerator/v16/Browse.VC.db
Binary file not shown.
Binary file not shown.
152 changes: 113 additions & 39 deletions RandomNameGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ int main()
srand((long)time(NULL)); //Seed the randum number generator...
do
{
printf("Choose a length for the First Name (2-5)\n");
cin >> lengthOfFirstName;
printf("Choose a length for the Last Name (2-5)\n");
cin >> lengthOfLastName;
printf("Choose a length for the First Name (2-5 0 for Random): "); cin >> lengthOfFirstName;
printf("Choose a length for the Last Name (2-5 0 for Random): "); cin >> lengthOfLastName;
NameGenFirstName(Name1);
NameGenLastName(Name2);
printf("\nFirst Name: %s", Name1);
Expand All @@ -73,10 +71,48 @@ char get_Char(void)

void NameGenFirstName(char* Name)
{

int iRandom = rand() % 6;

if (lengthOfFirstName <= 2)
int iRandom = rand() % 100 +1;
if (lengthOfFirstName == 0) {
if (iRandom <= 25)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (iRandom <= 50)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (iRandom <= 75)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (iRandom <= 100)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
}
else if (lengthOfFirstName <= 2)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 + 1]); //add the first syllable
Expand All @@ -86,76 +122,114 @@ void NameGenFirstName(char* Name)
}
else if (lengthOfFirstName == 3)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 + 1]); //add the first syllable
strcat(Name, syllables[rand() % 105 + 1]); //add the second syllable
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]); //Make the first letter capital...
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (lengthOfFirstName == 4)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 + 1]); //add the first syllable
strcat(Name, syllables[rand() % 105 + 1]); //add the second syllable
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]); //Make the first letter capital...
Name[0] = toupper(Name[0]);
return;
}
else if (lengthOfFirstName >= 5)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 + 1]); //add the first syllable
strcat(Name, syllables[rand() % 105 + 1]); //add the second syllable
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]); //Make the first letter capital...
Name[0] = toupper(Name[0]);
return;
}
}
void NameGenLastName(char* Name)
{

int iRandom = rand() % 6;

if (lengthOfLastName <= 2)
if (NameGenLastName == 0) {
if (iRandom <= 25)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (iRandom <= 50)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (iRandom <= 75)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (iRandom <= 100)
{
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
}
else if (lengthOfLastName <= 2)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 + 1]); //add the first syllable
strcat(Name, syllables[rand() % 105 + 1]); //add the second syllable
Name[0] = toupper(Name[0]); //Make the first letter capital...
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]);
return;
}
else if (lengthOfLastName == 3)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 + 1]); //add the first syllable
strcat(Name, syllables[rand() % 105 + 1]); //add the second syllable
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]); //Make the first letter capital...
Name[0] = toupper(Name[0]);
return;
}
else if (lengthOfLastName == 4)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 + 1]); //add the first syllable
strcat(Name, syllables[rand() % 105 + 1]); //add the second syllable
Name[0] = 0;
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]); //Make the first letter capital...
Name[0] = toupper(Name[0]);
return;
}
else if (lengthOfLastName >= 5)
{
Name[0] = 0; //Initialize the string to "" (zero length string)
strcat(Name, syllables[rand() % 105 +1]); //add the first syllable
strcat(Name, syllables[rand() % 105 + 1]); //add the second syllable
Name[0] = 0;
strcat(Name, syllables[rand() % 105 +1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
strcat(Name, syllables[rand() % 105 + 1]);
Name[0] = toupper(Name[0]); //Make the first letter capital...
Name[0] = toupper(Name[0]);
return;
}
}
Binary file not shown.
Binary file modified x64/Release/RandomNa.844C18CB.tlog/link.delete.1.tlog
Binary file not shown.
Binary file modified x64/Release/RandomNameGenerator.iobj
Binary file not shown.
Binary file modified x64/Release/RandomNameGenerator.ipdb
Binary file not shown.
4 changes: 2 additions & 2 deletions x64/Release/RandomNameGenerator.log
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
 RandomNameGenerator.cpp
Code wird generiert.
3 of 8 functions (37.5%) were compiled, the rest were copied from previous compilation.
2 functions were new in current compilation
0 of 8 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
0 functions had inline decision re-evaluated but remain unchanged
Codegenerierung ist abgeschlossen.
RandomNameGenerator.vcxproj -> C:\Users\snygg\OneDrive\_Visual Studio\projects\_cpp\RandomNameGenerator\x64\Release\RandomNameGenerator.exe
Binary file modified x64/Release/RandomNameGenerator.pdb
Binary file not shown.
Binary file modified x64/Release/vc142.pdb
Binary file not shown.

0 comments on commit 8bbc50b

Please sign in to comment.