1 #include <iostream> 2 3 using namespace std; 4 5 class weekday 6 { 7 private: 8 int num; 9 public: 10 void setday(){cin>>num;return;} 11 void incday(){num+=1;if(num>6) num-=7;return;} 12 void nowday() 13 { 14 switch(num) 15 { 16 case 0:cout<<"星期日"<<endl;break; 17 case 1:cout<<"星期一"<<endl;break; 18 case 2:cout<<"星期二"<<endl;break; 19 case 3:cout<<"星期三"<<endl;break; 20 case 4:cout<<"星期四"<<endl;break; 21 case 5:cout<<"星期五"<<endl;break; 22 case 6:cout<<"星期六"<<endl;break; 23 default:break; 24 } 25 } 26 }; 27 28 int main() 29 { 30 weekday one; 31 one.setday(); 32 one.nowday(); 33 one.incday(); 34 one.nowday(); 35 one.incday(); 36 one.nowday(); 37 return 0; 38 }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/600004.html