C + + Programming basics a 31-switch statement

Source: Internet
Author: User

1 //31-switch statement. CPP: Defines the entry point of the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7#include <array>8#include <math.h>9#include <string>Ten using namespacestd; One  A enumHerotype//  - { -Tank,//0 theMagic,//1 -Adc//2 -Assist//3 - }; +  - intMain () + { A     //SWITHC Statement Structure at     //switch (integer-expression)//an integer expression -     //{ -     //Case Lavel1: -     //statement1; -     //Beak; -     //Case Lavel2: in     //statement1; -     //Beak; to     //Default: +     //Break ; -     //} the       *Herotype type =Tank; $     Switch(type)Panax Notoginseng     { -      CaseTank: thecout <<"Using tank skills"<<Endl; +cout <<"using tank models"<<Endl; A          Break; the      CaseMagic: +cout <<"Using mage skills"<<Endl; -cout <<"using the wizard Model"<<Endl; $          Break; $      CaseADC: -cout <<"Use shooter Skills"<<Endl; -cout <<"using the shooter model"<<Endl; the          Break; -      CaseAssist:Wuyicout <<"Using assistive Skills"<<Endl; thecout <<"using the secondary model"<<Endl; -          Break; Wu     default: -cout <<"no corresponding hero type found"<<Endl; About          Break; $     } -  -     //Any switch statement can be replaced by a if...else statement. See the situation used.  -  A     intVIP =4; +     Switch(VIP) the     { -      Case 0: $cout <<"no presents ."<<Endl; the          Break; the      Case 1: thecout <<"Complimentary 10 Diamonds"<<Endl; the          Break; -      Case 2: incout <<"Complimentary 30 Diamonds"<<Endl; the          Break; the      Case 3: Aboutcout <<"Complimentary 50 Diamonds"<<Endl; the          Break; the      Case 4: thecout <<"Complimentary 100 Diamonds"<<Endl; +          Break; -     default: the          Break;Bayi     } the     intT; theCIN >>T; -     return 0; -}

C + + Programming basics a 31-switch statement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.