LuckySort Input: an array ary and the size of the array size while ary is not in order // assume you have a function to test this let i be a random integer between 0 and size-1 let j be a random integer between 0 and size-1 swap(ary[i],ary[j])
An algorithm is set of instructions that solves a problem in a finite amount of time.
Please note, there are three important pieces.
We tend to not want code in our design algorithms, but code is definitely a set of instructions.
To tell if the following is an algorithm, we need to test against those three items.
const integer expression is very important in my opinion
Note, these are things you can not do to an array
Also note, addition, subtraction, mod, division, and multiplication are the same type of operation, mathematics
Wile you can do these operations on an array, they do not work as anticipated
Note the difference in the two questions. One the compiler will catch for you, the other the compiler will not catch. You need to know the things you can do but will behave in an unexpected manner.
const size_t ARY_SIZE = 20;
string names[ARY_SIZE];
or
string names[20];
#ifndef GUARD_FOR_DOT_H_FILE
#deinfe GUARD_FOR_DOT_H_FILE
// code here
#endif
void StripString(string line) {
size_t i;
string rv;
for(i=0;i<line.size();i++) {
if (isalpha(line[i])) {
rv += line[i];
}
}
return line;
}