如何在代码中声明日期?不仅是星期天,还有其他日子。
#include <iostream>
using namespace std;
int main() {
int temperature;
char day = SUNDAY;
cout << "Enter your body temperature:" << endl ;
cin >> temperature ;
cout << "Enter what day:" << endl ;
cin >> day ;
if ((temperature > 40 ) && (day == SUNDAY))
cout << "Take sick certificate" << endl ;
else if (temperature > 40 )
cout << "Do a light work" << endl ;
else if (temperature > 50 )
cout << "Go to hospital!" << endl ;
else
cout << "Go to work" << endl ;
system("PAUSE");
return 0 ;
}
答案 0 :(得分:1)
申报日?您需要std::string
。我想你想要这样的东西:
#include <string>
....
std::string day = "SUNDAY";
....
if ((temperature > 40 ) && (day == "SUNDAY"))