枚举类型及定义新的类型名字

5、小作业:
课后自己练习定义枚举类型变量以及使用 typedef 定义新的类型名!

 

#include <iostream>
using namespace std;
enum Week
{
    Day1,
    Day2,
    Day3,
    Day4,
    Day5,
    Day6,
    Day7
};
typedef unsigned int uint;
union test
{
    char mark;
    long num;
    float score;
}student_1;
int main()
{
    Week day = Day2;
    switch (day)
    {
    case Day1:
        cout << "星期1" << endl;
        break;
    case Day2:
        cout << "星期2" << endl;
        break;
    case Day3:
        cout << "星期3" << endl;
        break;
    case Day4:
        cout << "星期4" << endl;
        break;
    case Day5:
        cout << "星期5" << endl;
        break;
    case Day6:
        cout << "星期6" << endl;
        break;
    case Day7:
        cout << "星期天" << endl;
        break;
    default:
        cout << "错误" << endl;
        break;
    }

    uint a = 1;
    cout << a << endl;

    student_1.num = 80;
    test student_2; 
    student_2.score = 10;
    cout << student_1.num << endl;
    cout << student_2.score << endl;
    
    return 0;
}

 

上一篇:Coursera | Using Python to Access Web Data(University of Michigan)| Quiz


下一篇:week 2020.12.27-2020.12.31