#include #include //for the iomanipulator setw #include #include //for class string using namespace std; int main() { string a[] { "", //dummy element has subscript 0 "partridge in a pear tree.", //so that this element will be 1 "turtledoves", //and this one will be 2 "French hens", // 3 "colly birds", // 4 "golden Rings", // 5 "geese a-laying", // 6 "swans a-swimming", // 7 "maids a-milking", // 8 "ladies dancing", // 9 "lords a-leaping", //10 "pipers piping", //11 "drummers drumming" //12 }; int ndays {size(a) - 1}; //number of days, not counting the dummy for (int day {1}; day <= ndays; ++day) { cout << "On the " << day; //Output the ordinal suffix for the number. if (day == 1) { cout << "st"; } else if (day == 2) { cout << "nd"; } else if (day == 3) { cout << "rd"; } else { cout << "th"; } cout << " day of Christmas\n" << "My true love gave to me\n"; for (int gift {day}; gift >= 1; --gift) { if (gift > 1) { cout << setw(2) << gift; } else if (day == 1) { cout << "A"; } else { cout << "And a"; } cout << " " << a[gift] << "\n"; } cout << "\n"; //Skip a line after each day. } return EXIT_SUCCESS; }