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 50 51 52
|
#include "stdafx.h" #include "Date.h" using namespace std;
string Constellation[12] = { "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "魔羯座" };
int main() { int mo = 0, day = 0;
while (mo <= 0 || mo >= 13) { cout << "Input month: "; while (!(cin >> mo)) { cout << "Invalid input, please input again! " << endl << "Input month: "; cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); } if (mo <= 0 || mo >= 13) cout << "Invalid input, please input again: " << endl; }
while (day <= 0 || day >= 31) { cout << "Input day: "; while (!(cin >> day)) { cout << "Invalid input, please input again: " << endl << "Input month: "; cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); } if (day <= 0 || day >= 31) cout << "Invalid input, please input again: " << endl; }
Date date(mo, day);
if (date.FindConsellation() != -1) cout << "你的星座是: " << Constellation[date.FindConsellation()] << endl;
return 0; }
|