#include #include #include // for class string using namespace std; int main( ) { const string a[ ] { "", // dummy element has subscript 0 "A partridge in a pear tree", // 1 "Two turtledoves", // 2 "Three French hens", // 3 "Four colly birds", // 4 "Five golden rings", // 5 "Six geese a-laying", // 6 "Seven swans a-swimming", // 7 "Eight maids a-milking", // 8 "Nine ladies dancing", // 9 "Ten lords a-leaping", // 10 "Eleven pipers piping", // 11 "Twelve drummers drumming" // 12 }; const string ordinals[] { "", // dummy element "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth" }; const size_t ndays {size(a) - 1}; // Don't count the dummy. for (int day {1}; day <= ndays; ++day) { cout << "On the " << ordinals[day] << " day of Christmas\n" << "My true love gave to me\n"; for (int gift {day}; gift >= 1; --gift) { if (gift == 1 && day != 1) { cout << "\tAnd " << a[gift] << "\n"; } else { cout << "\t" << a[gift] << "\n"; } } cout << "\n"; // Skip a line after each day. } return EXIT_SUCCESS; }