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
|
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void printmonth(const int month, const int startday, const bool leap);
int main(void)
{
printmonth(1,0,false); // Print January 1st, on a Sunday
printmonth(2,1,true); // Print February 1st leap year, on Monday
printmonth(1,2,false); // Print January 1st, on a Tuesday
printmonth(2,3,false); // Print February 1st not leap, on Wednesday
printmonth(1,4,false); // Print January 1st, on a Thursday
printmonth(2,5,false); // Print February 1st, on a Friday
printmonth(1,6,false); // Print January 1st, on a Saturday
printmonth(6,1,false); // Print June 1st, on Monday
printmonth(12,4,false); // Print December 1st, on a Thursday
return 0;
}
void printmonth(const int month, const int startday, const bool leap)
{
//define arrays
//declare three variables?
int count;
string monthArray[13]= {"null", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October",
"November", "December" };
string abbreviation[7] = { "Sun", "Mon", "Tue", "Thu", "Fri", "Sat" };
int daysArr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
if (leap == true) { //You remade a completely new varibale and wasn't even checking for equality == is equality = is assignment operator
daysArr[2] = 29;
}
cout << monthArray[month] << ": " << endl;
count = startday;
for (int i = 0; i < daysArr[month] - startday; i++) {
cout << abbreviation[count] << " ";
count++;
if (count == 7) {
count = 0;
cout << endl;
}
}
cout << endl << endl;
}
|