-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevonlib.cpp
More file actions
92 lines (74 loc) · 1.47 KB
/
Copy pathdevonlib.cpp
File metadata and controls
92 lines (74 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//Author: Devon Steinkoenig
//Title: Devon's Library
//File Name: devonlib.cpp
//Date Updated: 5/18/15
/*Description: A library of super useful stuff*/
#include "devonlib.h"
using namespace std;
/*Placeholder main() for testing purposes
int main()
{
char arr[64];
short num = 0;
short numStars = 0;
srand(time(NULL));
do
{
for ( short i = 0; i < 64; i++ )
{
if ( (arr[i] != '*') && (numStars < 40) )
{
num = rand() % 64;
if ( num < 40 )
{
arr[i] = '*';
++numStars;
} //if
else
arr[i] = ' ';
} //if
} //for i
} while ( numStars < 40 );
for ( short i = 0; i < 64; i++ )
{
cout<<arr[i];
if ( ((i + 1) % 8) == 0 )
cout<<endl;
} //for i
return 0;
}
*/
float myPower( const float base, const int power )
{
float numInProgress = 1;
for ( int i = 1; i <= power; i++)
{
numInProgress *= base;
} //for
return numInProgress;
} //myPower()
long myRand( const long min, const long max )
{
long randNum = 0;
randNum = ( rand() % ( ( max + 1 ) - min ) ) + min;
return randNum;
} //myRand()
long cStringL( char cString[] )
{
long count = 0;
do
{
if ( cString[count] != '\0' )
++count;
} while ( (cString[count] != '\0') );
return count;
} //cStringL()
long myAbs( const long num )
{
long val = 0;
if ( num >= 0 )
val = num;
else
val = -num;
return val;
} //myAbs()