2013-12-11 53 views
1

如何在我的代碼中聲明這一天?不僅是星期天,還有其他時間。如何申報一天?

#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

忘了作業標籤也許? –

+0

不,這只是嘗試和錯誤形式我自己 – user3089175

回答

1

申報日?您將需要std::string。我想你想要的東西是這樣的:

#include <string> 
.... 
std::string day = "SUNDAY"; 
.... 
if ((temperature > 40) && (day == "SUNDAY")) 
+0

好吧,讓我們試試吧 – user3089175

+0

確定它更好,之前, – user3089175

+0

我想如何把其他日子,或繼續重複這一步? – user3089175