switch函数的使用

switch…case函数:

int main(){
     
    int a;
    cout<<"Input date, please:"<<endl;
    cin>>a;
    switch(a){
     
        case 1: printf("Monday\n"); break;
        case 2: printf("Tuesday\n"); break;
        case 3: printf("Wednesday\n"); break;
        case 4: printf("Thursday\n"); break;
        case 5: printf("Friday\n"); break;
        case 6: printf("Saturday\n"); break;
        case 7: printf("Sunday\n"); break;
        default:printf("error\n"); break;
    }
    return 0;
}

你可能感兴趣的:(C++)