• 枚举


                              实例简单的输入今天的代码

    #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;

    }

  • 相关阅读:
    Django —— DateTimeField格式
    Django——权限组件(中间件判断用户权限--URL初级)
    linux命令
    性能测试--测试分类
    web安全之csrf攻击
    web安全之xss攻击
    测试用例规范
    禅道操作手册
    fiddler弱网测试
    Web测试系列之测试工具
  • 原文地址:https://www.cnblogs.com/fengbo/p/2657015.html
Copyright © 2020-2023  润新知