RagMasterRappy
11-18-2002, 11:34 AM
This is really easy to do, I can put the compiled Win32 executable somewhere if anyone wants it.
#include <stdio.h>
#define MAX_NAME_CHARS 12
#define MIN_VALID_CHAR 32
#define MAX_VALID_CHAR 126
int isValidName(char *name)
{
unsigned long i;
if (strlen(name) > MAX_NAME_CHARS)
return 0;
for (i=0; i<strlen(name); i++)
{
if (name[i] < MIN_VALID_CHAR || name[i] > MAX_VALID_CHAR)
return 0;
}
return 1;
}
unsigned long sumNameCharacters(char *name)
{
unsigned long result = 0;
unsigned long i;
for (i=0; i<strlen(name); i++)
result += name[i] % 10;
return result;
}
int main(int argc, char *argv[])
{
unsigned char *sectionIDNames[] = { "VIRDIA", "GREENILE", "SKYLY",
"BLUEFULL", "PURPLENIUM",
"PINKAL", "REDRIA", "ORAN",
"YELLOWBOZE", "WHITILL" };
if (argc < 2 || !isValidName(argv[1]))
{
fprintf(stderr, "PSO Section ID Calculatorn");
fprintf(stderr, "nUsage: sectid <your name>n");
fprintf(stderr, "Note that your name is limited to %d characters ", MAX_NAME_CHARS);
fprintf(stderr, "and can only includenalphanumeric ASCII characters!n");
return 1;
}
printf("%s's Section ID is %sn", argv[1],
sectionIDNames[sumNameCharacters(argv[1]) % 10]);
return 0;
}
#include <stdio.h>
#define MAX_NAME_CHARS 12
#define MIN_VALID_CHAR 32
#define MAX_VALID_CHAR 126
int isValidName(char *name)
{
unsigned long i;
if (strlen(name) > MAX_NAME_CHARS)
return 0;
for (i=0; i<strlen(name); i++)
{
if (name[i] < MIN_VALID_CHAR || name[i] > MAX_VALID_CHAR)
return 0;
}
return 1;
}
unsigned long sumNameCharacters(char *name)
{
unsigned long result = 0;
unsigned long i;
for (i=0; i<strlen(name); i++)
result += name[i] % 10;
return result;
}
int main(int argc, char *argv[])
{
unsigned char *sectionIDNames[] = { "VIRDIA", "GREENILE", "SKYLY",
"BLUEFULL", "PURPLENIUM",
"PINKAL", "REDRIA", "ORAN",
"YELLOWBOZE", "WHITILL" };
if (argc < 2 || !isValidName(argv[1]))
{
fprintf(stderr, "PSO Section ID Calculatorn");
fprintf(stderr, "nUsage: sectid <your name>n");
fprintf(stderr, "Note that your name is limited to %d characters ", MAX_NAME_CHARS);
fprintf(stderr, "and can only includenalphanumeric ASCII characters!n");
return 1;
}
printf("%s's Section ID is %sn", argv[1],
sectionIDNames[sumNameCharacters(argv[1]) % 10]);
return 0;
}