#26232: 求問哪裡錯? (C++)


EXOL (Judy)


//上學去吧!

 

#include<iostream>

using namespace std;

 

int main(){

 

int h, m;

 

while(cin >>h >> m){

 

if(h<7 or h>=17){ //7:00前 and 17:00後 

 

cout << "Off School" << endl;

}

 

else if(h=7 and m<30){ //7:00~7:29

 

cout << "Off School" << endl;

}

 

else{ //7:30~16:59

 

cout << "At School" << endl;

}

}

 

return 0;

}

#26845: Re:求問哪裡錯? (C++)


eheart (daniel)


//上學去吧!

 

#include

using namespace std;

 

int main(){

 

int h, m;

 

while(cin >>h >> m){

 

if(h=17){ //7:00前 and 17:00後 

 

cout << "Off School" << endl;

}

 

else if(h=7 and m<30){ //7:00~7:29

 

cout << "Off School" << endl;

}

 

else{ //7:30~16:59

 

cout << "At School" << endl;

}

}

 

return 0;

}

粗心了啦

這行 else if(h=7 and m<30){ //7:00~7:29

少一個等於
改成 else if(h==7 and m<30){ //7:00~7:29