请问计算星期几的程序怎么编,最简单的那种?
比如告诉你今天周三,再过四天是周几。
#include <iostream> #include <vector> using namespace std; int main() { int today,after; char *week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}; do { cout << "Today is week(1-7) : "; cin >> today; while (!getchar()); if (today >= 1 && today <= 7){ cout << "after : "; cin >> after; while (!getchar()); int valueafter = after % 7; int temp = today + valueafter - 1; if (temp > 7){ temp -= 7; } cout << "Today is " << week[today - 1] << ",after " << after << " days is " << week[temp] << endl; } if (0 == today){ break; } } while (1); return 0; }