C/C++の宿題を片付けます 52代目
■ このスレッドは過去ログ倉庫に格納されています
0492デフォルトの名無しさん
2005/11/08(火) 20:38:51#include <iostream>
#include <numeric>
using namespace std;
int date2days(int month, int day)
{
static char days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 };
return accumulate(days, days + month, day); // numeric
}
enum Day { SUN,MON,TUE,WED,THU,FRI,SAT };
ostream& operator<<(ostream& os, Day d) {
switch (d) {
case SUN: return os << "sun.";
case MON: return os << "mon.";
case TUE: return os << "tue.";
case WED: return os << "wed.";
case THU: return os << "thu.";
case FRI: return os << "fri.";
case SAT: return os << "sat.";
default: return os;
}
}
Day get_day(int days) { return Day((days + 5) % 7); }
int main()
{
int month, date;
cin >> month >> date;
int days(date2days(month, date));
Day day(get_day(days));
cout << days << ", " << day << endl;
}
■ このスレッドは過去ログ倉庫に格納されています