|
|
Shaz Color Picker Desktop, make your own color formats or
point your mouse in any part of the screen and get the color
formats in RGB, HTML, HEX, HSB, and CMYK.
(Try the application above)
Following are some C++ code which could be used as methods inside a class or as functions
and procedures at a structure design program.
int MyLibrary::GetRandomNo()
/*This method create a random no in range of 1 to 10000(change this no to get the random no in that range)
and return it.*/
{
int randomNo;
srand(time(0));
randomNo = 1+ rand() % 10000;
return randomNo;
}
int MyLibrary::StringToInteger(string Key)
/* this method converts a string to an integer. It assumed the integer is in range
of 1 to 10000. */
{
int Len;
bool KeyOk = true;
int num;
int mulby;
int intKey=0;
Len = Key.length(); // to get string length
for(int i=0; i < Len; ++i)
{
/*if any characters in the string is not a digit the whole string
is not an integer. */
if(isdigit(Key[i]) == false )
KeyOk = false; //the string is not an integer
}
if(KeyOk == true) // if the string is an integer
{
for(int j=0; j < Len; ++j) // change key from string to integer
{
num = GetInt(Key[j]); // get the equivalent integer number for
each individual character
mulby = GetFactor(Len - j); // get the number to be multiply by
intKey = intKey + (num * mulby); // in process to integer number
}
}
return intKey; // return the completed integer number
}
int MyLibrary::GetInt(char ch)
// this method converts a character number to an integer.
{
return (int(ch) - int('0'));
}
int MyLibrary::GetFactor(int Factor)
/* this method return a number for multiplication. Factor is the position of a
number in its integer number. */
{
int num;
/* Factor can not be more than 5, because GetRandomNo() method creates
a random number in the range of 1 to 10000.*/
switch (Factor)
{
case 5: num = 10000; // if a digit in string has the poistion of 5
break;
case 4: num = 1000; // if a digit in string has the poistion of 4
break;
case 3: num = 100; // if a digit in string has the poistion of 3
break;
case 2: num = 10; // if a digit in string has the poistion of 2
break;
case 1: num = 1; // if a digit in string has the poistion of 1
break;
}
return num;
}
|
|
|
|
|
57% OFF
|
|
29% OFF
|
|
20% OFF
|
|
35% OFF
|
|
|
Software Development Life Cycle
Software Development Life Cycle
|
|