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
|
#include <iostream>
#include <vector>
#include <ctime>
std::string cantBeSimpleNowCanIt(int);
inline void mySleep(clock_t);
int main() {
std::string xStr[] = {
"glitch in a pearl tree",
"algorithms",
"French tens",
"calling methods",
"golden strings",
"modulos a-dividing",
"arrays a-summing",
"bits a-byting",
"loops a-looping",
"longs a-heaping",
"pipelines piping",
"dumpers dumping",
};
std::vector<std::string> xMas (xStr, xStr + sizeof(xStr) / sizeof(std::string) );
for(std::vector<std::string>::iterator n = xMas.begin(); n < xMas.end(); n++) {
int nDay = std::distance(xMas.begin(), n) + 1;
std::cout << "\nOn the " << nDay << cantBeSimpleNowCanIt(nDay)
<< " day of xMas, my coding sent to me!\n";
mySleep(1);
for(std::vector<std::string>::iterator i = n; i >= xMas.begin(); i--) {
if(i == xMas.begin()) {
if (n == xMas.begin())
std::cout << "A";
else
std::cout << "And a";
} else {
std::cout << nDay;
}
std::cout << " " << *i << "\n";
nDay--; //high precision operation!
mySleep(1);
}
}
return 0;
}
std::string cantBeSimpleNowCanIt(int iDay) {
switch (iDay) {
case 1:
return "st";
break;
case 2:
return "nd";
break;
case 3:
return "rd";
break;
default:
return "th";
}
}
inline void mySleep(clock_t sec) //thanks Denis!
{
clock_t start_time = clock();
clock_t end_time = sec * 1000 + start_time;
while(clock() != end_time);
}
|