实例简单的输入今天的代码
#include<iostream>
using namespace std;
enum week{ sun, mon, tue, wed, thu, fri, sat, };
int main() {
week yesterday,tomorrow,today,day;
int code;
cout<<"0 sun,1 mon,2 tue,3 wed,4 thu,5 fri,6 sat"<<endl;
cout<<"请输入今天的代码:"<<endl; cin>>code;
switch(code) {
case 0:today=sun;break;
case 1:today=mon;break;
case 2:today=tue;break;
case 3:today=wed;break;
case 4:today=thu;break;
case 5:today=fri;break;
case 6:today=sat;break;
//case:default;
}
if(today==sun) yesterday=sat;
else yesterday=(week)(today-1);
if(today==sat) tomorrow=sun;
else tomorrow=(week)(today+1);
for(int i=1;i<4;i++) {
switch(i) {
case 1:day=today;break;
case 2:day=yesterday;break;
case 3:day=tomorrow;break;
}
switch(day){
case sun:{cout<<"Sunday"<<endl;break;}
case mon:cout<<"Monday"<<endl;break;
case tue:cout<<"Tuesday"<<endl;break;
case wed:cout<<"Wednesday"<<endl;break;
case thu:cout<<"Thursday"<<endl;break;
case fri:cout<<"Friday"<<endl;break;
case sat:cout<<"Saturday"<<endl;break;
}
}
return 0;
}
转载于:https://www.cnblogs.com/fengbo/archive/2012/08/25/2657015.html